Microsoft KB Archive/35657: Difference between revisions
m (Text replacement - "<" to "<") |
m (Text replacement - ">" to ">") |
||
Line 33: | Line 33: | ||
== SUMMARY == | == 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 < | 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:<br /> | ||
<br /> | <br /> | ||
DATA -1 | DATA -1 | ||
Line 52: | Line 52: | ||
RESTORE myCodeData | RESTORE myCodeData | ||
i% = 0 : a$ = "" | i% = 0 : a$ = "" | ||
WHILE a$ < | WHILE a$ <> "END" | ||
READ a$ | READ a$ | ||
IF a$ < | IF a$ <> "END" THEN code%(i%) = VAL(a$) :i% = i% + 1 | ||
WEND | WEND | ||
Latest revision as of 10:19, 21 July 2020
Article ID: 35657
Article Last Modified on 11/21/2006
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 **
Additional query words: MQuickB
Keywords: KB35657