HTBasic Help
×
Menu
Index

HP ASCII File Problem

The Hewlett-Packard BASIC Language Reference manual entry for "ENTER" states that "data should be entered into variables of the same type as those used to output it." This general rule applies to HTBasic as well, and if violated can produce unexpected results. Consider the following program:
 
10   CREATE "TEMP",1
20   ASSIGN @I TO "TEMP";FORMAT ON
30   OUTPUT @I;"1,2"
40   OUTPUT @I;"3,4"
50   RESET @I
60   ENTER @I;A,B
70   PRINT A,B
80   ASSIGN @I TO *
90   PURGE "TEMP"
100  END 
 
This program violates the matching-type rule by outputting strings and then entering numerics. Intuitively, you expect line 70 to print 1 and 2, which it does. When line 10 is changed to "CREATE BDAT", the same result is produced. But if line 10 is changed to "CREATE ASCII", then HP BASIC prints 1 and 3. Whether or not you consider this a bug in HP BASIC, it is a discrepancy that has been corrected in HTBasic. If you have written programs that use ASCII files and violate the matching-type rule, you should correct them before running them with HTBasic. If your program must run with both HP BASIC and HTBasic, you must either adhere to the matching-type rule, or use another file type.