#Superbase and Arexx
05-Aug-93 21:32:46
Sb: #61370-#Superbase and Arexx
Fm: Bob Chapman 76327,3116
To: Mark D. Manes 74030,744
Mark –
I can't tell you how much time I wasted before learning that it HAD to be
option NO RESULTS when you sent SBase a command and option RESULTS when you
were requesting a value (of a field, function, variable, whatever). It's
actually shown that way in the manual but never explained that it really has to
be NO RESULTS when a command is sent.
Although you didn't ask — and probably don't need it — my complete example
ARexx program follows 🙂 I have checked it with SBase4 v1.2 and v1.3. You may
be interested to note the use of GetAVal('STR$(FLD3,5,3)') instead of
GetAVal('FLD3') in the list all records loop. Its the only way I've found (so
far) to get more than two decimal places in a returned number and, of course,
to ARexx a string like 123.456 IS a good number.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
/* Add a SBase record (in file already OPEN of course) */
pival = 5000.236; fld1 = "045"
call SndACmd 'BLANK'
call SndACmd 'FLD1="'fld1'"'
call SndACmd 'FLD2="More and more stuff"'
call SndACmd 'FLD3='pival /* etc…. */
call SndACmd 'STORE'
/* Now list all records in the file */
call SndACmd 'SELECT FIRST'
call SndACmd 'VIEW'
do while GetAVal('EOF("")') = 0
say GetAVal('FLD1') left(GetAVal('FLD2'), 40) GetAVal('STR$(FLD3,5,3)')
call SndACmd 'SELECT NEXT'; call SndACmd 'VIEW'
end /* do while */
exit /* End of Example */
/* SndACmd(cmd) – Send CMD to SBase4 */
SndACmd: procedure
parse arg cmd
options no results /* 'NO results' for command to work */
rlabl = "snderr"
signal on error /* Trap SBPro's dumb 4096 'OK' return */
address 'SBase4' cmd /* Send the command */
snderr: signal off error
if (RC = 0 | RC = 4096) then
return 1
else
return 0
/* GetAVal(item) – Get Value from SBase4 */
GetAVal: procedure
parse arg item
options results /* need 'results' here */
rlabl = "geterr"
signal on error /* Trap SBase's dumb 4096 'OK' return */
address 'SBase4' item /* Send the item */
geterr: signal off error
if (RC = 0 | RC = 4096) then
return result
else
return "Error" RC
/* The ERROR handler */
ERROR: signal value rlabl /* return to the right procedure */
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
REC
——