28 April 2006
The Rexx/GDBM external functions are:
| GDBMOPEN( handle-variable-name, database-path, blocksize, read_write, mode ) |
Arguments:
| Access Type | "READER" | "WRITER" | "WRCREAT" | "NEWDB" |
|---|---|---|---|---|
| Function | read-only | read and write | create if non-existent | always create |
| Access Type | "UL_WRITER" | "UL_WRCREAT" | "UL_NEWDB" | No Lock | unlocked | unlocked | unlocked |
| GDBMSETOPT( handle, option,option value[,more option values,...] ) |
Arguments:
| Option | "CACHESIZE" | "SYNCMODE" | "CENTFREE" | "COALESCEBLKS" |
|---|---|---|---|---|
| Function | integer: number of cache buckets | boolean: write synchronously | boolean: centralize free pool | boolean: coalesce freed blocks |
| GDBMCLOSE( handle ) |
Arguments:
| GDBMSYNC( handle ) |
Arguments:
| GDBMREORGANIZE( handle ) |
Arguments:
| GDBMSTRERROR( ) |
Arguments:
| GDBMEXISTS(handle, key) |
Arguments:
| GDBMDELETE(handle, key) |
Arguments:
| GDBMINSERT( handle, key, data ) |
Arguments:
| GDBMREPLACE( handle, key, data ) |
Arguments:
| GDBMGETKEY( handle, key-variable-name ) |
Arguments:
| GDBMFETCH( handle, key, data-variable-name ) |
Arguments:
| GDBMLOADFUNCS() |
Although this function is useful only for dynamic library implementations of Rexx/GDBM, it can be called by the executable version of Rexx/GDBM. In this case it does nothing.
Arguments:
| GDBMDROPFUNCS() |
It should be called at the end of every Rexx/GDBM program. In particular, this function should be called after a syntax error has been caught with SIGNAL ON SYNTAX.
Arguments:
Internal Errors:
1 - Invalid gDBM Handle
2 - Invalid Boolean
3 - Invalid Number
4 - Invalid Option
5 - gDBM error from setopt
6 - Invalid read_write option
7 - Invalid filemode octal string
8 - Open error from gDBM
9 - Null key presented to GdbmFetch
10 - Null data presented to GdbmInsert/GdbmReplace
Call RXFuncAdd 'GDBMLoadFuncs','rexxgdbm','GDBMLoadFuncs'
Call GDBMLoadFuncs
ret = GdbmOpen( 'dbf', "/tmp/test.new.gdb", 4096, 'NEWDB', '644' )
If ret=0 then
Do
newkey_data = "new record stuff"
ret = GdbmInsert( dbf, "newkey", newkey_data )
If gdbmerror.intcode \= 0 Then Call Abort 'Error inserting record "newkey"'
If GdbmExists( dbf, "newkey" ) then do
ret = GdbmFetch( dbf, "newkey", 'outdata' )
If gdbmerror.intcode \= 0 then Call Abort 'Error retrieving "newkey" data'
end
Call GdbmClose dbf
End
Call GDBMDropFuncs
Return 0
Abort:
Parse Arg msg
Say msg
If gdbmerror.intcode = 1 Then Say 'Internal error:' gdbmerror.intcode gdbmerror.interrm
Else Say 'GDBM error:' gdbmerror.gdbmcode gdbmerror.gdbmerrm
Call GdbmClose dbf
Exit 1
|