Topic : The GFA-Basic Compendium Author : GFA Systemtechnik GmbH Version : GFABasic.HYP v2.98 (12/31/2023) Subject : Documentation/Programming Nodes : 899 Index Size : 28056 HCP-Version : 3 Compiled on : Atari @charset : atarist @lang : @default : Document not found @help : Help @options : +g -i -s +z @width : 75 @hostname : STRNGSRV @hostname : CAB @hostname : HIGHWIRE @hostname : THING View Ref-FileSTORE #i,x$() [,n [TO m]] RECALL #i,x$(),n [TO m] ,x i, n, m: iexp x$(): string array x: variable, at least 32-bit (long) The command STORE serves to save a string array as a text file (separated with CR/LF). The array is output through open channel i. The optional parameter n should contain the number of elements of the array that should be saved when used alone. With optional parameters n to m a partial array can be saved. If n TO m is omitted, the entire array is saved. DIM arr$(20) STORE #1,arr$() !store entire array 0 to 20 STORE #1,arr$(),10 !store elements 0 to 9 STORE #1,arr$(),5 TO 15 !store element 5 to 15 only The command RECALL serves to quickly read a string array from a text file. The array is read through open channel i. n lines of the text file are read into the array. If n is too large for the array dimension then the amount of text read is automatically limited (n=-1 reads the entire file). Optional paramaters n TO m work just like the STORE command. If the end of file is reached (EOF) then the input of text is ended with no error message. In each case variable x contains the number of strings read. DIM arr$(20) RECALL arr$(),-1,x% !read as much of text file as possible RECALL arr$(),10,x% !read 10 lines starting at element 0 RECALL arr$(),5 to 15,x% !read text into elements 5 to 15 only Note: STORE functions with files and peripheral devices, but RECALL only functions with files, since a SEEK (see following) is used internally. Counting always starts at zero. Examples: DIM A$(1000) FOR i%=0 TO 499 a$(i%)=STR$(RND) ! anything NEXT i% ' OPEN "o",#1,"TESTFILE.TXT" STORE #1,a$(),500 CLOSE #1 ' DIM b$(2000) OPEN "i",#1,"TESTFILE.TXT" RECALL #1,b$(),-1,x CLOSE #1 PRINT x --> The number of text lines read is displayed (500). PRINT "Line counter: " DIM a$(1000) DO FILESELECT "\*.*","",f$ EXIT IF f$="" lc%=0 OPEN "i",#1,f$ DO RECALL #1,a$(),-1,x% ADD lc%,x% LOOP WHILE x% CLOSE #1 PRINT f$'"contains"'lc%'"lines." LOOP --> This program counts the lines in text files. Memo: RECALL will crash if any line in the file exceeds about 9100 bytes in length when compiled. RECALL searches for ASCII 10 and not ASCII 13 as one might assume. Thus it will read unix text files, but not Apple text files. Fread()+, Fwrite()+