I'm having a problem with the UBOUND / LBOUND functions in PB3.5 with a VIRTUAL array shared between a main program and a PBU... Reduced to the essentials, the code is as follows:
main program code
INIF.PBU code
Now, the INIF.PBU code compiles just fine; no complaints from PB. Running the code, however, I get "Illegal Function Call" errors on the UBOUND/LBOUND statements in the PutINIParameter function - but not in the main program!
I've been able to verify that the IniParms() virtual array is being properly shared between the two, with a little test code that forces values into the array elements in the PBU and then prints them out in the Main, so... why doesn't the above code work properly?
------------------
main program code
Code:
$LINK "inif.pbu" DECLARE FUNCTION PutINIParameter?(string, string) DIM VIRTUAL IniParms(100) AS STRING * 64 SHARED IniParms() CLS PRINT UBOUND(IniParms()) PRINT LBOUND(IniParms()) FOR Q = 0 to 15 X = PutINIParameter?("ALEPH", "TEXTVAL") PRINT X NEXT Q
Code:
$COMPILE UNIT DIM VIRTUAL IniParms(100) AS STRING * 64 SHARED IniParms() FUNCTION PutINIParameter?(ParameterName$, ParameterVal$) PUBLIC SHARED IniParms() LOCAL EntrySlot? EntrySlot? = LBOUND(IniParms()) 'get lowermost entry slot in array DO IF IniParms(EntrySlot?) = STRING$(64,0) THEN EXIT DO INCR EntrySlot? LOOP UNTIL EntrySlot? > UBOUND(IniParms()) IF EntrySlot? <= UBOUND(IniParms) THEN IniParms(EntrySlot?) = ParameterVal$ PutINIParameter? = -1 ELSE PutINIParameter? = 0 END IF END FUNCTION
Now, the INIF.PBU code compiles just fine; no complaints from PB. Running the code, however, I get "Illegal Function Call" errors on the UBOUND/LBOUND statements in the PutINIParameter function - but not in the main program!
I've been able to verify that the IniParms() virtual array is being properly shared between the two, with a little test code that forces values into the array elements in the PBU and then prints them out in the Main, so... why doesn't the above code work properly?
------------------
Comment