From ben at versaccounting.com Tue Jul 5 13:49:23 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Can S-Lang do this ? Message-ID: <42CAC823.5000508@versaccounting.com> I have 95% completed the SLAG menu/screen routines. Just need to add a "Generic" Formatter for display (and reports) as well as some sort of list/scroll routine. However, I was wondering on enhancing the SLAG eXPerience, can S-Lang's interpreter , if given a set of parameters that are part of my SLAG routines, automagically decode embedded parameters before doing the final parameter? Example: (loosely prototype) define return_data_value ( file_no, field_no ) { variable data_field ; data_field = getdata(file_no, field_no ) ; % C file accress routine return data_field ; } .... ...... slang code ..... ......................... % NOTE: row, col, rs, cs, and Refsh are all integer values input_rtn ( row, col, rs, cs, "A", return_data_value (1, 12 ), Refsh ) ; Where in the ABOVE "input_rtn", S-lang executes return_value and pushes that on to the stack AFTER having pushed Refsh and before the rest and then calling "input_rtn". ALSO .. thinking of changing my name of the project from SLAG to SLADE - for S-lang Application Development Environment, since there is no 'real' application generator in place yet? Any Comments ? -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From ben at versaccounting.com Tue Jul 5 17:44:16 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLANGFUN and arrays ..... Message-ID: <42CAFF30.3000503@versaccounting.com> Ok, inside of S-Lang. Is there ways to add to arrays (of strings), insert into an array and remove an array entry ? Thanks ... -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From mnoble at space.mit.edu Tue Jul 5 18:13:11 2005 From: mnoble at space.mit.edu (Michael Noble) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLANGFUN and arrays ..... In-Reply-To: <42CAFF30.3000503@versaccounting.com> References: <42CAFF30.3000503@versaccounting.com> Message-ID: <20050705221311.GA10354@svoboda.mit.edu> > Ok, inside of S-Lang. Is there ways to add to arrays (of strings), insert > into an array and remove an array entry ? Adding elements to the beginning or end of any kind of array is clean and easy. For example, slsh> variable s = ["two"]; slsh> s = [s, "three"]; slsh> s = ["one", s]; slsh> foreach(s) { variable elem = (); vmessage(elem); } one two three slsh> Index arrays can be used to contract an array (remove elements). E.g. slsh> s = s[[0,2]]; slsh> foreach(s) { variable elem = (); vmessage(elem); } one three slsh> This kind of operation will likely involve the creation of temporary arrays, so keep performance in mind for large arrays or perhaps trade off to associative arrays to conserve space/memory and time (removal would happen in O(1) time simply setting array["string_index"] = NULL or something). HTH, Mike From p.boekholt at hetnet.nl Tue Jul 5 19:34:24 2005 From: p.boekholt at hetnet.nl (Paul Boekholt) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLANGFUN and arrays ..... In-Reply-To: <20050705221311.GA10354@svoboda.mit.edu> Message-ID: <1Dpwvo-05l-00@earth.cosmos.com> On Tue, 5 Jul 2005 18:13:11 -0400, Michael Noble said: > This kind of operation will likely involve the creation of temporary > arrays, so keep performance in mind for large arrays or perhaps trade > off to associative arrays to conserve space/memory and time (removal > would happen in O(1) time simply setting array["string_index"] = NULL > or something). Or use a list. From the manual: The most important difference between an array and a list is that an array's size is fixed whereas a list may grow or shrink. Algorithms that require such a data structure may execute many times faster when a list is used instead of an array. From davis at space.mit.edu Wed Jul 6 10:44:30 2005 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Can S-Lang do this ? In-Reply-To: <42CAC823.5000508@versaccounting.com> References: <42CAC823.5000508@versaccounting.com> Message-ID: <200507061444.j66EiUFc009848@aluche.mit.edu> Ben Duncan wrote: >input_rtn ( row, col, rs, cs, "A", return_data_value (1, 12 ), Refsh ) ; > >Where in the ABOVE "input_rtn", S-lang executes return_value and pushes that on >to the stack AFTER having pushed Refsh and before the rest and then calling > "input_rtn". Are you asking that the parameters in the parameter list be evaluated in a particular order? Does `return_data_value` have side-effects where Refsh, row, etc are modified? If so, then you may need to make the function call like: row1 = row; col1 = col; . . Refsh1 = Refsh; val = return_data_value (1, 12); input_rtn (row1, col1, ..., val, Refsh1); Thanks, --John From davis at space.mit.edu Wed Jul 6 10:46:46 2005 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLANGFUN and arrays ..... In-Reply-To: <20050705221311.GA10354@svoboda.mit.edu> References: <42CAFF30.3000503@versaccounting.com> <20050705221311.GA10354@svoboda.mit.edu> Message-ID: <200507061446.j66Ekkx5009868@aluche.mit.edu> Michael Noble wrote: >Adding elements to the beginning or end of any kind of array is clean >and easy. For example, > > slsh> variable s = ["two"]; It is worth pointing out that at the slsh prompt, there is no need to declare variables. That is, slsh> s = ["two"]; should work. --John From davis at space.mit.edu Wed Jul 6 10:58:49 2005 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLANGFUN and arrays ..... In-Reply-To: <1Dpwvo-05l-00@earth.cosmos.com> References: <1Dpwvo-05l-00@earth.cosmos.com> Message-ID: <200507061458.j66EwnPY009915@aluche.mit.edu> Paul Boekholt wrote: >Or use a list. From the manual: Right. One advantage of the list over the array is that an element may be easily inserted/appended at any position using the list_insert and list_append functions. Elements may be removed using the list_delete and list_pop functions. At the moment, lists do not support support "slices", i.e., one cannot use even_elements = list[[0::2]]; odd_elements = list[[1::2]]; to create lists from the even and odd elements of the list. If you need such a feature, then an array may be more appropriate. Eventually, lists will support the slicing operation. --John From ben at versaccounting.com Wed Jul 6 12:46:14 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLANGFUN and arrays ..... In-Reply-To: <200507061458.j66EwnPY009915@aluche.mit.edu> References: <1Dpwvo-05l-00@earth.cosmos.com> <200507061458.j66EwnPY009915@aluche.mit.edu> Message-ID: <42CC0AD6.3000801@versaccounting.com> Now, If we can store these in a "keyed" file out to disk, in a multi user mode, we WOULD have a PICK/XML Native data file manager for S-lang and ALL my current worries would be solved ;-> .... John E. Davis wrote: > Paul Boekholt wrote: > >>Or use a list. From the manual: > > > Right. One advantage of the list over the array is that an element > may be easily inserted/appended at any position using the list_insert > and list_append functions. Elements may be removed using the > list_delete and list_pop functions. > > At the moment, lists do not support support "slices", i.e., one cannot > use > > even_elements = list[[0::2]]; > odd_elements = list[[1::2]]; > > to create lists from the even and odd elements of the list. If you > need such a feature, then an array may be more appropriate. > Eventually, lists will support the slicing operation. > > --John > > _______________________________________________ > To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html > -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From ben at versaccounting.com Wed Jul 6 12:49:43 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Can S-Lang do this ? In-Reply-To: <200507061444.j66EiUFc009848@aluche.mit.edu> References: <42CAC823.5000508@versaccounting.com> <200507061444.j66EiUFc009848@aluche.mit.edu> Message-ID: <42CC0BA7.2060908@versaccounting.com> Yes, where it is evaluated in a particular order and .. No, return_data_value simply returns a "string" as a parameter to the rest of the function call. John E. Davis wrote: > Ben Duncan wrote: > >>input_rtn ( row, col, rs, cs, "A", return_data_value (1, 12 ), Refsh ) ; >> >>Where in the ABOVE "input_rtn", S-lang executes return_value and pushes that on >>to the stack AFTER having pushed Refsh and before the rest and then calling >> "input_rtn". > > > Are you asking that the parameters in the parameter list be evaluated > in a particular order? Does `return_data_value` have side-effects > where Refsh, row, etc are modified? If so, then you may need to make > the function call like: > > row1 = row; > col1 = col; > . > . > Refsh1 = Refsh; > val = return_data_value (1, 12); > input_rtn (row1, col1, ..., val, Refsh1); > > Thanks, > --John > -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From joerg at alea.gnuu.de Fri Jul 8 05:14:24 2005 From: joerg at alea.gnuu.de (Joerg Sommer) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Bug in slsh Message-ID: Hi John, '!if (s[1]) message("foo")' needs _two_ semicolons. slsh> !if (s[1]) message("foo");; foo slsh> !if (s[1]) message("foo"); ; foo slsh> Regards, J?rg. -- Je planm??iger ein Mensch vorgeht, desto st?rker mag ihn der Zufall treffen. Erich Krunau "Die Physiker" From davis at space.mit.edu Fri Jul 8 09:39:05 2005 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Bug in slsh In-Reply-To: References: Message-ID: <200507081339.j68Dd5Kh005164@aluche.mit.edu> Joerg Sommer wrote: >'!if (s[1]) message("foo")' needs _two_ semicolons. > >slsh> !if (s[1]) message("foo");; >foo >slsh> !if (s[1]) message("foo"); > > ; >foo It is not really a bug. The parser is waiting for the next token, which could be an "else", in order to complete the statement. --John From dburke at cfa.harvard.edu Wed Jul 13 11:55:51 2005 From: dburke at cfa.harvard.edu (Doug Burke) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Do I have to free MMT objects which are accessed from an array? Message-ID: <8d3c402ce387686f8f0a2fadff093c55@cfa.harvard.edu> I have defined my own type/class and want to access an array of them from C, so I gave something like (ignoring error checking): SLang_Array_Type *at; SLang_MMT_Type *mmt = NULL; int dims; (void) SLang_pop_array_of_type (&at, my_type); /* access the first element */ dims = 0; (void) SLang_get_array_element (at, &zero, &mmt); I can then handle mmt as I want. The question I have is do I need to call SLang_free_mmt() on mmt once I've finished using it? Thanks, Doug From davis at space.mit.edu Wed Jul 13 12:08:24 2005 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Do I have to free MMT objects which are accessed from an array? In-Reply-To: <8d3c402ce387686f8f0a2fadff093c55@cfa.harvard.edu> References: <8d3c402ce387686f8f0a2fadff093c55@cfa.harvard.edu> Message-ID: <200507131608.j6DG8Oxt003627@aluche.mit.edu> Doug Burke wrote: > (void) SLang_pop_array_of_type (&at, my_type); > > /* access the first element */ > dims = 0; > (void) SLang_get_array_element (at, &zero, &mmt); > >I can then handle mmt as I want. The question I have is do I need to >call >SLang_free_mmt() on mmt once I've finished using it? Yes, you have to free both the mmt and the array when you are finished. --John From ben at versaccounting.com Wed Jul 13 12:03:22 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Berkley SleepyCat DBM Message-ID: <42D53B4A.2010305@versaccounting.com> Anyone have any experience using the Berkeley SleepyCat DBM routines? I am still SEARCHING for some sort of DBM module to use in my SLAG project .. Thanks ... -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From dburke at cfa.harvard.edu Wed Jul 13 12:55:06 2005 From: dburke at cfa.harvard.edu (Doug Burke) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Do I have to free MMT objects which are accessed from an array? In-Reply-To: <200507131608.j6DG8Oxt003627@aluche.mit.edu> References: <8d3c402ce387686f8f0a2fadff093c55@cfa.harvard.edu> <200507131608.j6DG8Oxt003627@aluche.mit.edu> Message-ID: <7b44717c211c5d809aedebc621418bab@cfa.harvard.edu> On Jul 13, 2005, at 12:08 PM, John E. Davis wrote: > Doug Burke wrote: >> (void) SLang_pop_array_of_type (&at, my_type); >> >> /* access the first element */ >> dims = 0; >> (void) SLang_get_array_element (at, &zero, &mmt); >> >> I can then handle mmt as I want. The question I have is do I need to >> call >> SLang_free_mmt() on mmt once I've finished using it? > > Yes, you have to free both the mmt and the array when you are finished. > > --John > Thanks, it wasn't clear to me whether SLang_get_array_element was increasing the reference count of the mmt. Doug From ben at versaccounting.com Wed Jul 13 14:32:33 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Slang modules and threads? In-Reply-To: <427ED452.1030607@mchsi.com> References: <1DUPpX-07H-00@earth.cosmos.com> <427ED452.1030607@mchsi.com> Message-ID: <42D55E41.8060109@versaccounting.com> Ok, am taking a VERY serious LOOK at Sleepy Cat DBM as my SLAG database engine. As covered before, I am crossing the bridge on "threads". To wit from the Berkeley DB Manual/Guide: ---------------------------------------------------------------------------------------- The Big Picture: The previous chapters in this Reference Guide have described applications that use the Berkeley DB access methods for fast data storage and retrieval. The applications described in the following chapters are similar in nature to the access method applications, but they are also threaded and/or recoverable in the face of application or system failure. ----------------------------------------------------------------------------------------- Ok, PAUL suggested using "STATIC". Is that as in Static compile/link the module? What Am I on the lookout here for? What do I need to avoid doing ? Thanks ... -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From ben at versaccounting.com Thu Jul 14 08:38:24 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Slang modules and threads? In-Reply-To: <1DszHN-03i-00@earth.cosmos.com> References: <1DszHN-03i-00@earth.cosmos.com> Message-ID: <42D65CC0.9000200@versaccounting.com> Ok, Thanks very much to Paul for some answers. To clarify some things he pointed out: SLAG is designed to be database independent from the onset. It is simply a lot of LOWER S-lang C Routines rolled up into a few simple functions. And as John pointed about SLWDG, his library works just to damn well. ;-> However, the idea is that when (and if) I can ever get around to doing a RAD/IDE they need some sort of file system and the "Application" side needs some control files as well. My thoughts was that whatever I used, could become a "basic" multiuser database engine , without the developer having to bring an outside DBM, which would speed adoption and usage of SLAG. I do NOT wish to tie SLAG to any particular DBM, and as it sits right now, it is just PURE S-Lang and C function calls to CSLANG stuff. I Guess 14 years of working on Multi Value (PICK like) databases has spoiled me. You do not worry about fixed field lengths, typing, or layouts since MV databases treat all fields as strings. A data dictionary to the File told the DBM how to return the field to the program (a PRAGMA as it were). The nice thing was those Multi values, so in a something like an Order Entry File, you could store the "detail" line items and all of their information in the same record, but those where like an array. What you got was a ROW record that could contain "COLUMNS" of fields (like looking at a spreadsheet). I fact, Appgens database manager is nothing more than a Key/Data type DBM that has had some stuff added to to it. Paul, do you think this could be emulated using T/GDBM ? /* AppGen Database File system * db_int.h : The internal structure of a database (DB) file. */ /* * _db_fia maps the Fixed Information Area at the beginning of each DB. */ #define DB_APPEND_ONLY 0x01 #define DB_FREELISTS 10 /* Number of FREELISTS */ typedef struct { unsign short _padword; /* space no longer used */ unsign short _opens; /* number of opens on this db */ byte _openlock; /* file opens have been locked out */ byte _flags; /* flag bits */ byte _fia_align[2]; /* 32-bit alignment */ long _reccount; /* number of bytes in record */ long _hashsize; /* current number of hash table slots */ /* in low 3 bytes, high byte determines */ /* which of several functions to use */ DBOFF _hashstart; /* offset to the hash table */ long _minsize; /* Minimum record size */ long _overpct; /* Minimum percentage overhead */ struct { long size; /* Max size on this list */ DBOFF offset; /* Offset to the first block */ } _freestart[DB_FREELISTS]; /* An array of Freelists */ } _db_fia; /* Define the structure that was used for 1.7 and previous * releases. Needed for dbar in conversion mode. */ typedef struct { unsign short _padword; /* space no longer used */ unsign short _opens; /* number of opens on this db */ long _hashsize; /* current number of hash table slots */ /* in low 3 bytes, high byte determines */ /* which of several functions to use */ DBOFF _hashstart; /* offset to the hash table */ DBOFF _freestart; /* offset to the freelist table */ byte _openlock; /* file opens have been locked out */ byte _fia_align[3]; /* 32-bit alignment */ } _db_fia17; /* * _db_block maps a generalized block in a db */ typedef struct { long _blocklen; /* current block length (bytes) */ long _bytesused; /* number of bytes in use */ DBOFF _next; /* -> to next block, or NULL */ DBOFF _prev; /* -> to previous block, or NULL */ byte _type; /* type of this block */ byte _reclock; /* flag set if record is locked */ unsign short _rdcount; /* number of non-lock reads */ byte _rec_align[4]; /* alignment for 64 bit system */ } _db_block; /* * _db_data maps a block header plus a portion of the data area */ typedef struct { long _blocklen; /* current block length (bytes) */ long _bytesused; /* number of bytes in use */ DBOFF _next; /* -> next block, or NULL */ DBOFF _prev; /* -> previous block, or NULL */ byte _type; /* record type (locked or unlocked) */ byte _reclock; /* flag set if record is locked */ unsign short _rdcount; /* number of non-lock reads */ byte _rec_align[4]; /* alignment for 64 bit system */ char _recdata[DB_MAXKEY]; /* a portion of the data */ } _db_data; /* * Data Record and Freelist Entry types: */ # define EMPTY 1 /* this entry is not in use */ /* iff no one is reading it. */ # define DATA 2 /* contains live data */ # define HASHSTORE 5 /* this entry is a hash table */ /* * poly-functional hashing stuff */ # define HASHAPART(n) ((int) ((n) >> 24) & 0x00ff) # define HASHSPART(n) ((n) & 0x00ffffff) # define HASHSIZE(f) HASHSPART((f)->_hashsize) # define HASHPARM(s,a) (HASHSPART(s) | (((long)(a)) << 24)) # define OLDHASH 0 # define NEWHASH 1 /* * attribute and value marks */ # define ATRIBMARK 0x0000 /* Row Delimeters */ # define VALUEMARK 0x00ff /* Field Delimeters */ /* use MARKCMP when comparing against */ /* a MARK to avoid sign extension */ # define MARKCMP(m) ( ((int) (m)) & 0x00ff ) /* * other stuff */ # define DB_REP 1 # define DB_INS 2 # define DB_DEL 4 /* System Compile Time Defaults */ # define DB_MINREC 128 # define DB_OVERPCT 20 # define DB_FLINCR 128 /* * data */ extern _db_fia _fiabuf; extern _db_data _datbuf; extern int _db_ccnt, _db_acnt, _db_vcnt; /* * functions */ extern long _db_hash(); /* calculate the hash function */ extern int _db_bdump(); /* write the buffer chain to the file */ extern int _db_frel(); /* release the record in the file */ extern int _db_mrel(); /* release the record in memory */ extern int _db_seek(); /* locate a field in the memory record */ extern int _db_splice(); /* perform surgery on the memory record */ extern void _db_kread(); /* take the first buffer from _datbuf */ extern void _db_sread(); /* for readnext, copy from seq buffer */ #ifdef CPLUSPLUS extern long _db_get(CHANNEL ch, char buf[], CHOFF loc, long len); #else extern long _db_get(); /* vm_get() with error checking */ #endif extern long _db_put(); /* vm_put() with error checking */ # define GETFIA(db) _db_get(db->db_fd,(char*)&_fiabuf,(long) sizeof(_db_fia),0L) # define PUTFIA(db) _db_put(db->db_fd,(char*)&_fiabuf,(long) sizeof(_db_fia),0L) # define GETBLK(db,loc) _db_get(db->db_fd,(char*)&_datbuf, \ (long) sizeof(_db_block),loc) # define PUTBLK(db,loc) _db_put(db->db_fd,(char*)&_datbuf, \ (long) sizeof(_db_block),loc) Paul Boekholt wrote: > On Wed, 13 Jul 2005 13:32:33 -0500, Ben Duncan said: > > >>Ok, am taking a VERY serious LOOK at Sleepy Cat DBM as my SLAG database engine. > > If you use Sleepy Cat as your database engine and I need to write an > application that uses a MySQL database, can I still use SLAG? I think there > are three possible answers: > -No. Then SLAG will not be very useful. FWIW I'm currently working on an > almost trivial database (in PHP) but a key/value pairs DBM would not do. > -Yes. Then you can just finish SLAG and worry about databases later. > -Yes, but you still need the DBM as well because SLAG needs to store some > configuration variables there. GDBM should be able to do that just as well. > > -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From p.boekholt at hetnet.nl Thu Jul 14 11:17:26 2005 From: p.boekholt at hetnet.nl (Paul Boekholt) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Slang modules and threads? In-Reply-To: <42D65CC0.9000200@versaccounting.com> Message-ID: <1Dt5So-04n-00@earth.cosmos.com> On Thu, 14 Jul 2005 07:38:24 -0500, Ben Duncan said: > Paul, do you think this could be emulated using T/GDBM ? Do you mean tdb? You can store multiple values in a DBM record, just separate them by commas or whatever. However relational databases were designed for this, and also allow searching on any field. From ben at versaccounting.com Thu Jul 14 13:11:40 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] Slang modules and threads? In-Reply-To: <1Dt5So-04n-00@earth.cosmos.com> References: <1Dt5So-04n-00@earth.cosmos.com> Message-ID: <42D69CCC.1020502@versaccounting.com> There is a TDBM that is done by the SAMBA group - multiple readers AND writers. Anyway, Yes I know that relational databases are designed to do that. It is that I am breaking things down to their simpliest form. Keeping it to simple commands/functions such as ye old COBOL uses: Read, Read Next, Read Previous ,Write, Start key, Delete, and the like. Having fields pushed and poped by: slang_attr = GET_ATTR(FD, FIELD_no, MV_NO) ; PUSH_ATTR(FD, FIELD_NO, MV_NO, slang_attr) ; (where FD and Field_no can be Numbers of NAMES, where by the names are converted to numbers by the function from that data dictionary). This elminates the "small" users from having their "step-sons first cousin who is a SQL/DBM expert is coming in to enhance and optimize that SQL database we have. Yeah he is an expert, done that PLENTY of time on his PS2 and ACCESS database" (been there , done that, did not like it!). Sooo.... Now we have the best of both worlds. The runtime and RAD/IDE uses a DBM, but the Functions could care less about the database backend. They are just pushing and pop'ing data stacks. But at the simpliest level, the applications can use the DBM method, whilst allowing the bigger sophisticated users to use a SQL database methods. Hmm .. which brings up another point, Why does "RELATIONAL" database mean to so many people that they have a "relative" that is a "DATABASE" expert? ;-> Paul Boekholt wrote: > On Thu, 14 Jul 2005 07:38:24 -0500, Ben Duncan said: > > >>Paul, do you think this could be emulated using T/GDBM ? > > > Do you mean tdb? You can store multiple values in a DBM record, just > separate them by commas or whatever. However relational databases were > designed for this, and also allow searching on any field. > > _______________________________________________ > To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html > -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From p.boekholt at hetnet.nl Mon Jul 18 05:58:37 2005 From: p.boekholt at hetnet.nl (Paul Boekholt) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] sltdb module Message-ID: <1DuSOT-04V-00@earth.cosmos.com> Hello, I've made a module for Andrew Tridgell's TDB library (http://sourceforge.net/projects/tdb). It's similar to the gdbm module, except that it allows multiple writers. You can get it from http://www.cheesit.com/downloads/slang/sltdb. From ben at versaccounting.com Mon Jul 18 09:37:24 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] sltdb module In-Reply-To: <1DuSOT-04V-00@earth.cosmos.com> References: <1DuSOT-04V-00@earth.cosmos.com> Message-ID: <42DBB094.6000303@versaccounting.com> Many thanks to PAUL on this ... BTW, what do you think of this database engine? http://www.mysql.com/products/maxdb/ Seems it is based upon SAP-DB, which was Adabas-D at one time... Paul Boekholt wrote: > Hello, > > I've made a module for Andrew Tridgell's TDB library > (http://sourceforge.net/projects/tdb). It's similar to the gdbm > module, except that it allows multiple writers. You can get it from > http://www.cheesit.com/downloads/slang/sltdb. > > _______________________________________________ > To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html > -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From ben at versaccounting.com Mon Jul 18 10:46:48 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] TIme Routines. Message-ID: <42DBC0D8.7050300@versaccounting.com> Anybody know of how to get mktime or has a routine to return time values BEFORE the Epoch (12/31/1969). I was working on my "TIME HASH" routine to store time in SLAG when I discovered, mktime does not work with dates prior to the above .... Any Suggestions ? -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From davis at space.mit.edu Mon Jul 18 12:15:06 2005 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] TIme Routines. In-Reply-To: <42DBC0D8.7050300@versaccounting.com> References: <42DBC0D8.7050300@versaccounting.com> Message-ID: <200507181615.j6IGF6IX001441@aluche.mit.edu> Ben Duncan wrote: >Anybody know of how to get mktime or has a routine to return >time values BEFORE the Epoch (12/31/1969). I have no problem with such values under Linux (debian woody, using glibc): slsh> tm = localtime (-100000000); slsh> print (tm); {tm_sec=20, tm_min=13, tm_hour=9, tm_mday=31, tm_mon=9, tm_year=66, tm_wday=1, tm_yday=303, tm_isdst=0} slsh> mktime (tm); -100000000 What OS are you using? FWIW, here are some routines that I use to convert Unix time_t values to and from Julian dates: % This algorithm came from the calendar FAQ, and appears to have been derived % from "A Machine Algorithm for Processing Calendar Dates" % by Fliegel and Flandern in Communications of the ACM from 1968. define tms_to_jd (tms) { variable month = tms.tm_mon + 1; variable a = (14 - month)/12; variable y = (1900+tms.tm_year)+4800-a; variable m = month + 12*a - 3; variable day = tms.tm_mday; variable jd = day + (153*m+2)/5 + y*365 + y/4 - y/100 + y/400 - 32045; % The julian day begins at noon jd -= 0.5; return jd + (tms.tm_hour + (tms.tm_min + tms.tm_sec/60.0)/60.0)/24.0; } define tms_to_mjd (tms) { return tms_to_jd (tms) - 2400000.5; } define unix_to_mjd (t) { return tms_to_mjd (gmtime (t)); } define mjd_to_unix (mjd) { variable t0 = 0; variable t1 = 0x7FFFFFFFU; variable mjd0 = unix_to_mjd (t0); variable mjd1 = unix_to_mjd (t1); if ((mjd0 > mjd) or (mjd > mjd1)) verror ("%S: date cannot be represented as a unix time_t", _function_name); forever { variable t = t0 + (t1-t0)/2; variable mjd2 = unix_to_mjd (t); if (mjd2 <= mjd) { if (mjd2 == mjd) return t; mjd0 = mjd2; t0 = t; continue; } mjd1 = mjd2; t1 = t; } } define mjd_to_year (mjd) { variable t = mjd_to_unix (mjd); variable tm = gmtime (t); variable y = 1900.0 + tm.tm_year; variable d = tm.tm_yday + (tm.tm_hour + (tm.tm_min+tm.tm_sec/60.0)/60.0)/24.0; y += d/365.0; return y; } From ben at versaccounting.com Mon Jul 18 12:56:20 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] TIme Routines. In-Reply-To: <200507181615.j6IGF6IX001441@aluche.mit.edu> References: <42DBC0D8.7050300@versaccounting.com> <200507181615.j6IGF6IX001441@aluche.mit.edu> Message-ID: <42DBDF34.7090103@versaccounting.com> Slackware 10.1 .....glibc Ran your routine and got back a -1 from mktime .. John E. Davis wrote: > Ben Duncan wrote: > >>Anybody know of how to get mktime or has a routine to return >>time values BEFORE the Epoch (12/31/1969). > > > I have no problem with such values under Linux (debian woody, using > glibc): > > slsh> tm = localtime (-100000000); > slsh> print (tm); > {tm_sec=20, tm_min=13, tm_hour=9, tm_mday=31, tm_mon=9, tm_year=66, tm_wday=1, tm_yday=303, tm_isdst=0} > slsh> mktime (tm); > -100000000 > > What OS are you using? > > FWIW, here are some routines that I use to convert Unix time_t values > to and from Julian dates: > > % This algorithm came from the calendar FAQ, and appears to have been derived > % from "A Machine Algorithm for Processing Calendar Dates" > % by Fliegel and Flandern in Communications of the ACM from 1968. > define tms_to_jd (tms) > { > variable month = tms.tm_mon + 1; > variable a = (14 - month)/12; > variable y = (1900+tms.tm_year)+4800-a; > variable m = month + 12*a - 3; > variable day = tms.tm_mday; > > variable jd = day + (153*m+2)/5 + y*365 + y/4 - y/100 + y/400 - 32045; > > % The julian day begins at noon > jd -= 0.5; > return jd + (tms.tm_hour + (tms.tm_min + tms.tm_sec/60.0)/60.0)/24.0; > } > > define tms_to_mjd (tms) > { > return tms_to_jd (tms) - 2400000.5; > } > > > define unix_to_mjd (t) > { > return tms_to_mjd (gmtime (t)); > } > > define mjd_to_unix (mjd) > { > variable t0 = 0; > variable t1 = 0x7FFFFFFFU; > variable mjd0 = unix_to_mjd (t0); > variable mjd1 = unix_to_mjd (t1); > > if ((mjd0 > mjd) or (mjd > mjd1)) > verror ("%S: date cannot be represented as a unix time_t", _function_name); > > forever > { > variable t = t0 + (t1-t0)/2; > variable mjd2 = unix_to_mjd (t); > > if (mjd2 <= mjd) > { > if (mjd2 == mjd) > return t; > > mjd0 = mjd2; > t0 = t; > continue; > } > mjd1 = mjd2; > t1 = t; > } > } > > define mjd_to_year (mjd) > { > variable t = mjd_to_unix (mjd); > variable tm = gmtime (t); > variable y = 1900.0 + tm.tm_year; > variable d = tm.tm_yday + (tm.tm_hour + (tm.tm_min+tm.tm_sec/60.0)/60.0)/24.0; > y += d/365.0; > return y; > } > > -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From Laurent.Perez at greyc.ensicaen.fr Mon Jul 18 14:03:55 2005 From: Laurent.Perez at greyc.ensicaen.fr (Laurent Perez) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] TIme Routines. In-Reply-To: <42DBDF34.7090103@versaccounting.com> References: <42DBC0D8.7050300@versaccounting.com> <200507181615.j6IGF6IX001441@aluche.mit.edu> <42DBDF34.7090103@versaccounting.com> Message-ID: <20050718180355.GB2897@greyc.ensicaen.fr> * Ben Duncan [2005-07-18 11:56] : > Slackware 10.1 .....glibc > > Ran your routine and got back a -1 from mktime .. I am using Slackware 10.1 too and got the same as John : slsh> tm = localtime (-100000000); slsh> print (tm); {tm_sec=20, tm_min=13, tm_hour=15, tm_mday=31, tm_mon=9, tm_year=66, tm_wday=1, tm_yday=303, tm_isdst=0} slsh> mktime (tm); -100000000 S-Lang Library Version: 2.0.4 Anyway, was there something before the Epoch ? ;^) From jmrobert5 at mchsi.com Mon Jul 18 14:27:13 2005 From: jmrobert5 at mchsi.com (jmrobert5@mchsi.com) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] TIme Routines. Message-ID: <071820051827.26924.42DBF481000AF9240000692C2197913363CA9B9D0A0D019D0306@mchsi.com> I don't know what to tell you. But I also run Slackware 10.1, and I got similar results to John. So its not inherit to Slackware per se. I am running Slang 2.0.0 with the first patch. Is your /lib/libc-2.3.4 ??? maybe it got changed/updated to something else? A puzzler... -- Joe Robertson jmrobert5@mchsi.com http://home.mchsi.com/~jmrobert5/ > Slackware 10.1 .....glibc > > Ran your routine and got back a -1 from mktime .. > > John E. Davis wrote: > > Ben Duncan wrote: > > > >>Anybody know of how to get mktime or has a routine to return > >>time values BEFORE the Epoch (12/31/1969). > > > > > > I have no problem with such values under Linux (debian woody, using > > glibc): > > > > slsh> tm = localtime (-100000000); > > slsh> print (tm); > > {tm_sec=20, tm_min=13, tm_hour=9, tm_mday=31, tm_mon=9, tm_year=66, > tm_wday=1, tm_yday=303, tm_isdst=0} > > slsh> mktime (tm); > > -100000000 > > > > What OS are you using? > > > > FWIW, here are some routines that I use to convert Unix time_t values > > to and from Julian dates: > > > > % This algorithm came from the calendar FAQ, and appears to have been derived > > % from "A Machine Algorithm for Processing Calendar Dates" > > % by Fliegel and Flandern in Communications of the ACM from 1968. > > define tms_to_jd (tms) > > { > > variable month = tms.tm_mon + 1; > > variable a = (14 - month)/12; > > variable y = (1900+tms.tm_year)+4800-a; > > variable m = month + 12*a - 3; > > variable day = tms.tm_mday; > > > > variable jd = day + (153*m+2)/5 + y*365 + y/4 - y/100 + y/400 - 32045; > > > > % The julian day begins at noon > > jd -= 0.5; > > return jd + (tms.tm_hour + (tms.tm_min + tms.tm_sec/60.0)/60.0)/24.0; > > } > > > > define tms_to_mjd (tms) > > { > > return tms_to_jd (tms) - 2400000.5; > > } > > > > > > define unix_to_mjd (t) > > { > > return tms_to_mjd (gmtime (t)); > > } > > > > define mjd_to_unix (mjd) > > { > > variable t0 = 0; > > variable t1 = 0x7FFFFFFFU; > > variable mjd0 = unix_to_mjd (t0); > > variable mjd1 = unix_to_mjd (t1); > > > > if ((mjd0 > mjd) or (mjd > mjd1)) > > verror ("%S: date cannot be represented as a unix time_t", > _function_name); > > > > forever > > { > > variable t = t0 + (t1-t0)/2; > > variable mjd2 = unix_to_mjd (t); > > > > if (mjd2 <= mjd) > > { > > if (mjd2 == mjd) > > return t; > > > > mjd0 = mjd2; > > t0 = t; > > continue; > > } > > mjd1 = mjd2; > > t1 = t; > > } > > } > > > > define mjd_to_year (mjd) > > { > > variable t = mjd_to_unix (mjd); > > variable tm = gmtime (t); > > variable y = 1900.0 + tm.tm_year; > > variable d = tm.tm_yday + (tm.tm_hour + > (tm.tm_min+tm.tm_sec/60.0)/60.0)/24.0; > > y += d/365.0; > > return y; > > } > > > > > > -- > Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 > "Never attribute to malice, that which can be adequately explained by stupidity" > - Hanlon's Razor > > > _______________________________________________ > To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html From ben at versaccounting.com Mon Jul 18 14:57:38 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] TIme Routines. In-Reply-To: <071820051827.26924.42DBF481000AF9240000692C2197913363CA9B9D0A0D019D0306@mchsi.com> References: <071820051827.26924.42DBF481000AF9240000692C2197913363CA9B9D0A0D019D0306@mchsi.com> Message-ID: <42DBFBA2.4040909@versaccounting.com> Whoooa ... weird .... Slackware 10.1 but says libc-2.3.3-2.so .... This was one That I did a "swaret" update on. Maybe time to do a CD update ... ANYWAY FWIW: I have gotten a hold of a DATE routine that will do days/dates from Jan 1, 2000 baseline (a little more modern). It based upon the SETI's RingLib routines. This will do days prior to year 1582 and WAY out past 4000 A.D. It is a fairly straight forward calculation routine and is not dependant on any library. When I get finished stripping it and converting it to my needs (M/D/Y -> #(+/-) of days and #(+/-) of days to -> M/D/Y ) from baseline, does anyone want me to post the program? jmrobert5@mchsi.com wrote: > I don't know what to tell you. But I also run Slackware 10.1, and I got similar > results to John. So its not inherit to Slackware per se. > > I am running Slang 2.0.0 with the first patch. > > Is your /lib/libc-2.3.4 ??? maybe it got changed/updated to something else? > > A puzzler... > -- > Joe Robertson > jmrobert5@mchsi.com > http://home.mchsi.com/~jmrobert5/ > > > >>Slackware 10.1 .....glibc >> >>Ran your routine and got back a -1 from mktime .. >> >>John E. Davis wrote: >> >>>Ben Duncan wrote: >>> >>> >>>>Anybody know of how to get mktime or has a routine to return >>>>time values BEFORE the Epoch (12/31/1969). >>> >>> >>>I have no problem with such values under Linux (debian woody, using >>>glibc): >>> >>> slsh> tm = localtime (-100000000); >>> slsh> print (tm); >>> {tm_sec=20, tm_min=13, tm_hour=9, tm_mday=31, tm_mon=9, tm_year=66, >> >>tm_wday=1, tm_yday=303, tm_isdst=0} >> >>> slsh> mktime (tm); >>> -100000000 >>> >>>What OS are you using? >>> >>>FWIW, here are some routines that I use to convert Unix time_t values >>>to and from Julian dates: >>> >>>% This algorithm came from the calendar FAQ, and appears to have been derived >>>% from "A Machine Algorithm for Processing Calendar Dates" >>>% by Fliegel and Flandern in Communications of the ACM from 1968. >>>define tms_to_jd (tms) >>>{ >>> variable month = tms.tm_mon + 1; >>> variable a = (14 - month)/12; >>> variable y = (1900+tms.tm_year)+4800-a; >>> variable m = month + 12*a - 3; >>> variable day = tms.tm_mday; >>> >>> variable jd = day + (153*m+2)/5 + y*365 + y/4 - y/100 + y/400 - 32045; >>> >>> % The julian day begins at noon >>> jd -= 0.5; >>> return jd + (tms.tm_hour + (tms.tm_min + tms.tm_sec/60.0)/60.0)/24.0; >>>} >>> >>>define tms_to_mjd (tms) >>>{ >>> return tms_to_jd (tms) - 2400000.5; >>>} >>> >>> >>>define unix_to_mjd (t) >>>{ >>> return tms_to_mjd (gmtime (t)); >>>} >>> >>>define mjd_to_unix (mjd) >>>{ >>> variable t0 = 0; >>> variable t1 = 0x7FFFFFFFU; >>> variable mjd0 = unix_to_mjd (t0); >>> variable mjd1 = unix_to_mjd (t1); >>> >>> if ((mjd0 > mjd) or (mjd > mjd1)) >>> verror ("%S: date cannot be represented as a unix time_t", >> >>_function_name); >> >>> forever >>> { >>> variable t = t0 + (t1-t0)/2; >>> variable mjd2 = unix_to_mjd (t); >>> >>> if (mjd2 <= mjd) >>> { >>> if (mjd2 == mjd) >>> return t; >>> >>> mjd0 = mjd2; >>> t0 = t; >>> continue; >>> } >>> mjd1 = mjd2; >>> t1 = t; >>> } >>>} >>> >>>define mjd_to_year (mjd) >>>{ >>> variable t = mjd_to_unix (mjd); >>> variable tm = gmtime (t); >>> variable y = 1900.0 + tm.tm_year; >>> variable d = tm.tm_yday + (tm.tm_hour + >> >>(tm.tm_min+tm.tm_sec/60.0)/60.0)/24.0; >> >>> y += d/365.0; >>> return y; >>>} >>> >>> >> >>-- >>Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 >>"Never attribute to malice, that which can be adequately explained by stupidity" >> - Hanlon's Razor >> >> >>_______________________________________________ >>To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html > > -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From davis at space.mit.edu Mon Jul 18 16:21:13 2005 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] TIme Routines. In-Reply-To: <071820051827.26924.42DBF481000AF9240000692C2197913363CA9B9D0A0D019D0306@mchsi.com> References: <071820051827.26924.42DBF481000AF9240000692C2197913363CA9B9D0A0D019D0306@mchsi.com> Message-ID: <200507182021.j6IKLDT0004143@aluche.mit.edu> jmrobert5@mchsi.com wrote: >A puzzler... Apparantly, newer versions of glibc return -1 when the tm struct has a value before the epoch. This is because various standards require mktime to return -1 upon error. As a result, how does one distinguish one second before the epoch from an error? The way solaris handles this is via errno, i.e., errno=0; if (((time_t)-1 == (secs = mktime(&tm))) && errno) { /* error occurred */ . . } I would have preferred glibc to adopt a similar approach. For now one work-around would be to write a slang routine to "solve" for the value of t such that tm = localtime (t); where tm is given. A binary search (bisection) algorithm would probably work best. In fact, before mktime was added to slang, I wrote my own version of mktime using such a method: define my_mktime (tm) { variable secs1 = _time (); variable secs0 = 0; while (secs1 != secs0) { variable tm_1 = localtime (secs1); variable tm_0 = localtime (secs0); variable secs = (secs0 + secs1)/2; variable tm2 = localtime (secs); if (tm2.tm_year > tm.tm_year) { secs1 = secs; continue; } if (tm2.tm_year < tm.tm_year) { secs0 = secs; continue; } if (tm2.tm_mon > tm.tm_mon) { secs1 = secs; continue; } if (tm2.tm_mon < tm.tm_mon) { secs0 = secs; continue; } if (tm2.tm_mday > tm.tm_mday) { secs1 = secs; continue; } if (tm2.tm_mday < tm.tm_mday) { secs0 = secs; continue; } if (tm2.tm_hour > tm.tm_hour) { secs1 = secs; continue; } if (tm2.tm_hour < tm.tm_hour) { secs0 = secs; continue; } if (tm2.tm_min > tm.tm_min) { secs1 = secs; continue; } if (tm2.tm_min < tm.tm_min) { secs0 = secs; continue; } if (tm2.tm_sec > tm.tm_sec) { secs1 = secs; continue; } if (tm2.tm_sec < tm.tm_sec) { secs0 = secs; continue; } break; } return secs0; }