Hello! I’m relatively new to UniVerse and Multi-valued databases, so my experience with BASIC is limited.
I was writing a program with subroutine calls that I wanted to abstract via ‘@<var>’. This program had a “create output file data line” subroutine and a “finalize output file” subroutine. When I wrote these local subroutines (explicitly defined, not subroutine labels), I encountered an error where, when calling with ‘@’, only the first locally-defined subroutine would be found; the other subroutine would cause a runtime error, unable to be located. It was not found locally, and so the object database file (.O) was being searched, instead.
For example:
* ...
IS.DONE = @FALSE
* Main loop
LOOP
READNEXT FILE.NAME ELSE
IS.DONE = @TRUE
END
UNTIL IS.DONE
* ...
OUPUT.FILE = ""
PREPARE.DATA.SUBR = ""
FINALIZE.FILE.SUBR = ""
* case 1
BEGIN CASE
CASE FILE.TYPE = TYPE.1
PREPARE.DATA.SUBR = "DO.SOMETHING.1"
FINALIZE.FILE.SUBR = "END.FILE.1"
CASE FILE.TYPE = TYPE.2
PREPARE.DATA.SUBR = "DO.SOMETHING.2"
FINALIZE.FILE.SUBR = "END.FILE.2"
CASE 1
* LOG ERROR
CONTINUE
END CASE
* ...
READ DATA.FILE FROM FILES, FILE.NAME ELSE
* HANDLE ERROR
END
DATA.LINE.COUNT = DCOUNT(DATA.FILE, @FM)
FOR LINE = 1 TO DATA.LINE.COUNT
DATA.LINE = DATA.FILE<LINE>
* ...
IF PREPARE.DATA.SUBR # "" THEN
CALL @PREPARE.DATA.SUBR(OUTPUT.FILE, DATA.LINE)
END
NEXT LINE
* ...
IF FINALIZE.FILE.SUBR # "" THEN
CALL @FINALIZE.FILE.SUBR(OUTPUT.FILE)
END
* ...
REPEAT; * End main loop
* program clean up
* ...
END; * program
* Subroutines *****************************************
* DO.SOMETHING.1 would be the only subroutine found, others
* called with @ will cause a runtime error
SUBROUTINE DO.SOMETHING.1(OUTPUT.FILE, DATA.LINE)
* ...
END; * DO.SOMETHING.1
SUBROUTINE DO.SOMETHING.2(OUTPUT.FILE, DATA.LINE)
* ...
END; * DO.SOMETHING.2
SUBROUTINE END.FILE.1(OUTPUT.FILE)
* ...
END; * END.FILE.1
SUBROUTINE END.FILE.2(OUTPUT.FILE)
* ...
END; * END.FILE.2Calling the subroutines explicitly (with their actual name, i.e. ‘CALL DO.SOMETHING.1(...)’) did not result in runtime errors. Oddly enough, this error did not occur when testing with other, smaller programs. I was able to define two separate locally-defined subroutines and call them without runtime crashes.
I decided to go with explicit calls in this program to avoid any other issues, but I am curious as to why this had occurred in the first place.
Has anyone else encountered this behavior before and is able to explain what UniVerse does in the background to handle calls with ‘@<var>’? I understand that the search for the subroutines begins in the local/program scope and move outward towards the various catalogs, but is there more that I may be missing?
Thank you in advance to anyone able to help!