Microsoft KB Archive/64498

= How to Define a String Array in FIELDs in a FOR...NEXT Loop =

Article ID: 64498

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft BASIC Interpreter 1.0
 * Microsoft BASIC Interpreter 1.01 for Macintosh
 * Microsoft BASIC Interpreter 2.0
 * Microsoft BASIC Interpreter 2.1 for Macintosh
 * Microsoft BASIC Interpreter 3.0 for Macintosh
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 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 &quot;test.dat&quot; 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) = &quot;1234567890&quot; LSET F$(15) = &quot;ABCDEFGHIJ&quot; PUT #1, 1 CLOSE

OPEN &quot;test.dat&quot; 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)

