home *** CD-ROM | disk | FTP | other *** search
- *************
- * Deck "DBBaseDeck"
- *************
-
- *************
- * Card(s) in deck.
- * Card "CARD#1"
- *************
- * 1 Card(s), 1 were printed.
- *************
-
- *************
- * Natural order of Cards
- * Card "CARD#1"
- *************
-
- *************
- * Global Routine(s) in deck.
- * Routine "Add Entry"
- * Routine "Delete Entry"
- * Routine "Display Entry"
- * Routine "Load Database"
- * Routine "Next Entry"
- * Routine "Previous Entry"
- * Routine "Save Database"
- * Routine "Search For Entry"
- * Routine "Sort DataBase"
- *************
- * 9 Global routines(s), 9 were printed.
- *************
-
- *************
- * Card "CARD#1"
- AfterAttachment
- Let DataFile = "Ram:TestDB.DAT"
- Do "Load Database"
- EndScript
- Window "UserWindow"
- Definition
- Origin 0,0
- Size 320,200
- Title ""
- NumberOfColors 16
- DefaultColors 0,1,0
- WindowObjects CLOSEBUTTON DEPTHBUTTONS DRAGBAR
- WindowFlags ACTIVATE TOFRONT WORKBENCH
- VisualEffects NONE ,WAIT
- EndScript
- OnCloseButton
- Quit
- EndScript
- EndObject
- * End of Card "CARD#1"
- *************
-
- *************
- * Global routine "Add Entry"
- Let DataBase[Index] = GetDBOBjects ; save current entry
- Let Index = Index + 1 ; insert it at next index
- InsertArrayEntry DataBase,Index ; make space for it
- Do "Display Entry"
- * End of routine "Add Entry"
- *************
-
- *************
- * Global routine "Delete Entry"
- DeleteArrayEntry DataBase,Index ; delete this dude
- If VarType(DataBase[Index]) = "Nothing" ; check if last(end) entry
- Let Index = LastArrayIndex(DataBase); find new last(end) entry
- EndIf
- Do "Display Entry"
- * End of routine "Delete Entry"
- *************
-
- *************
- * Global routine "Display Entry"
- SetDBObjects DataBase[Index] ; display Entry
- SetWindowTitle "Entry #" || Index
- * End of routine "Display Entry"
- *************
-
- *************
- * Global routine "Load Database"
- Dispose DataBase ; get rid of current
- If Exists(DataFile) ; check if file exists
- Let DataBase = LoadVariable(DataFile) ; load it
- IfError ;this simple example does nothing for an error
- EndIf ;you can do something like display a requester
- EndIf
- Let Index = FirstArrayIndex(DataBase) ; go to first entry
- Do "Display Entry"
- * End of routine "Load Database"
- *************
-
- *************
- * Global routine "Next Entry"
- Let DataBase[Index] = GetDBOBjects ; Save Entry
- Let Index = NextArrayIndex(DataBase,Index) ; Look for Next entry
- If Not SearchFound ; Check if at end
- Let Index = FirstArrayIndex(DataBase) ; go to first one
- EndIf
- Do "Display Entry"
- * End of routine "Next Entry"
- *************
-
- *************
- * Global routine "Previous Entry"
- Let DataBase[Index] = GetDBOBjects ; save entry
- Let Index = PreviousArrayIndex(DataBase,Index) ; find previous
- If Not SearchFound ; if not one
- Let Index = LastArrayIndex(DataBase) ; go to last one
- EndIf
- Do "Display Entry"
- * End of routine "Previous Entry"
- *************
-
- *************
- * Global routine "Save Database"
- Let DataBase[Index] = GetDBObjects ; save current entry
- SaveVariable DataBase,DataFile ; save it
- IfError ;this simple example does not do anything for an error
- EndIf ;however, you can do something like display a requester
- * End of routine "Save Database"
- *************
-
- *************
- * Global routine "Search For Entry"
- Nop; ARG1 = "Search Value"
- Nop; ARG2 = "Search Key"
- Nop; example - Do "Search For Entry","Henry",".Name"
- Nop
- Let DataBase[Index] = GetDBOBjects ; Save Entry
- SetSearchArrayFlags NOCASE SUBSTRING
- Let OldIndex = Index ;save index in case Arg1 is not found
- Let Index = SearchArray(DataBase,Arg1,Arg2,Index+1) ; search from next index
- If Not SearchFound ; Check if found it
- Let Index = SearchArray(DataBase,Arg1,Arg2) ; search from beginning
- If Not SearchFound
- Let Index = OldIndex ;not found - goto original index
- EndIf
- EndIf
- Do "Display Entry" ; Display it!
- * End of routine "Search For Entry"
- *************
-
- *************
- * Global routine "Sort DataBase"
- Nop ; ARG1 = "Sort key"
- Nop ; example - Do "Sort DataBase",".Name"
- Nop
- Let DataBase[Index] = GetDBOBjects ; Save Entry
- SortArray DataBase,NOCASE STRING ,ARG1 ; Sort Data
- Let Index = FirstArrayIndex(DataBase) ; go to first one
- Do "Display Entry"
- * End of routine "Sort DataBase"
- *************
-
-