"Out of Data"; Incorrect CALL Example Mac QuickBASIC Page 61 (35657)






This article was previously published under Q35657

SUMMARY

The example for the CALL statement on Page 61 of the "Microsoft QuickBASIC for Apple Macintosh: BASIC Language Reference" manual is incorrect. The example produces an "Out of data" error because the condition for the WHILE... WEND loop is "A <> -1"; however, there is not a data statement that sets A equal to -1. The following additional line needs to be added at the end of the code:

DATA -1

MORE INFORMATION

The example is still not a very good one even with the "DATA -1" statement, because you cannot substitute machine-language code that contains a literal value of -1. The machine-language routine would only be read in up to the first "-1", and the resulting partial machine-language routine would probably hang (crash) when invoked.

The example should be rewritten to read the machine code as strings first, since there is no number that cannot appear in machine code. That way, we can signal the end with the string "END", and the same BASIC statements can be used to read any machine language.

The following is a code example:
DIM code%(50)    'big enough to hold all our machine code

'    this loop can be used to read in ANY machine code
RESTORE myCodeData
i% = 0 : a$ = ""
WHILE a$ <> "END"
    READ a$
    IF a$ <> "END" THEN code%(i%) = VAL(a$) :i% = i% + 1
WEND

myCodeData:
DATA ...
     ... machine code defined as hex constants
     ...
DATA "END"    :'**   End of machine-language routine   **
				

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: KB35657