Re: Basic Euphoria Sequences
- Posted by don cole <doncole at pacbell.net> Feb 10, 2006
- 478 views
ags wrote: > > This is not a specific answer (as sequences themselves are so versatile) but > some practices I use. They may or may not suit you. > > If I'm using sequences as records, I always define constants for the 'fields' > eg: > }}} <eucode> > sequence records > > constant REC_ID = 1, -- atom > REC_NAME = 2, -- string sequence > REC_DATE = 3, -- DateTime sequence structure > REC_DIRENT = 4, -- output of dir(...) > REC_PATH = 5 -- string sequence > > </eucode> {{{ > > I then immediately manually define a 'blank' record. This allows you to have > certain defaults if you wish not to fill out all of them at the time of record > creation. It also gives you a visual clue of what your records look like: > }}} <eucode> > constant blank_record = {-1, "", {}, {}, ""} > </eucode> {{{ > > When creating a new record I fill in a copy of the blank record: > }}} <eucode> > sequence newrec > newrec = blank_record > newrec[REC_ID] = get_next_id() -- as an example > newrec[REC_NAME] = file_name > newrec[REC_DATE] = nowDateTime() > newrec[REC_DIRENT] = dir(current_path & "\\" & file_name) > newrec[REC_PATH] = current_path > </eucode> {{{ > Then I append the new record to the sequence containing the records: > }}} <eucode> > records = append(records, newrec) This I highly approve of. Don Cole A Bug is an un-documented feature. A Feature is a documented Bug. >