How to Define a String Array in FIELDs in a FOR...NEXT Loop (64498)
The information in this article applies to:
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
- Microsoft BASIC Interpreter for Apple Macintosh 1.0
- Microsoft BASIC Interpreter for Apple Macintosh 1.01
- Microsoft BASIC Interpreter for Apple Macintosh 2.0
- Microsoft BASIC Interpreter for Apple Macintosh 2.1
- Microsoft BASIC Interpreter for Apple Macintosh 3.0
- Microsoft QuickBASIC 4.0
- Microsoft QuickBASIC 4.0b
- Microsoft QuickBASIC 4.5
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
- Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
- Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.1
- Microsoft GW-BASIC 3.2
- Microsoft GW-BASIC 3.22
- Microsoft GW-BASIC 3.23
This article was previously published under Q64498 SUMMARY
Below is an example of defining a string array in multiple FIELD
statements invoked in a FOR ... NEXT loop.
Code Example
(Note: To run this program in GW-BASIC, you must add a line number to
each line.)
OPEN "test.dat" AS #1 LEN = 300
DIM F$(30)
i = 1
FOR j = 1 TO 10
FIELD #1, (j - 1) * 30 AS temp$, 10 AS F$(i), 10 AS F$(i + 1), 10 AS F$(i +
2)
i = i + 3
NEXT
LSET F$(30) = "1234567890"
LSET F$(15) = "ABCDEFGHIJ"
PUT #1, 1
CLOSE
OPEN "test.dat" AS #1 LEN = 300
i = 1
FOR j = 1 TO 10
FIELD #1, (j - 1) * 30 AS temp$, 10 AS F$(i), 10 AS F$(i + 1), 10 AS F$(i +
2)
i = i + 3
NEXT
GET #1, 1
PRINT F$(30), F$(15)
REFERENCES
For more information about alternatives to multiple FIELD statements
in the latest Microsoft BASIC products, query for a separate article
in this Knowledge Base using the following words:
Microsoft BASIC Professional Development System (PDS) versions 7.00
and 7.10 for MS-DOS and MS OS/2 introduce the ability to have arrays
in user-defined TYPEs, which allows you to write an array to disk all
at once. For more information, query for a separate article in this
Knowledge Base using the following words:
RANDOM and BINARY and PUT and Array and TYPE
Modification Type: | Minor | Last Reviewed: | 8/16/2005 |
---|
Keywords: | KB64498 |
---|
|