02-08-2023, 12:34 AM
(This post was last modified: 02-08-2023, 12:49 AM by TempodiBasic.)
@Dimster
going on with your pseudocode
I followed the instruction of Bplus to create a text file with the data posted by Bplus for the "The File" that I saved as "The File.txt".
so I took your pseudocode and I translated it to QB64
look at this
if you run this code, you get an infinite loop that reads only the first 7 data from the file, because SEEK #1,1 resets the file pointer to the first byte of the same file.
and if we want to let working this code we can:
use DataCount as SHARED variable
or
use DataCount as parameter of SUB Recur
or
use DataCount as STATIC variable of SUB Recur
or
use SUB Recur STATIC
....
at yours the choice
in this case you'll get twice the first 7 data from the file.
If you want to get also the second set of 7 data from the file, you need REMming SEEK #1,1.
going on with your pseudocode
I followed the instruction of Bplus to create a text file with the data posted by Bplus for the "The File" that I saved as "The File.txt".
so I took your pseudocode and I translated it to QB64
look at this
Code: (Select All)
Open "The file.txt" For Input As #1 'Open File
Recur
Close #1
End
Sub Recur
Dim DataItem(1 To 7) As String ' we define a variable to read text from file
LoopRecur = LoopRecur + 1 ' this is a alone variable that does not pass to the next recursive calling
Seek #1, 1 ' this force to read file from the first byte... so we read always the same 7 string data
For i = 1 To 7: Input #1, DataItem(i): Next
DataCount = DataCount + 7 ' this is another alone variable that does not pass to the next recursive calling
WorkDataItem DataItem() 'Call Subroutine to work on these 7 data items
If DataCount < 14 Then Recur ' this condition it will never happen because DataCount at each run is always 0 and becomes 7
End Sub
Sub WorkDataItem (s() As String)
For i = 1 To 7 Step 1
Color i, i-1
Print s(i); " ";
Next i
Color 7 ' restore the default color foreground for text
Print ' we go ahead
_Delay .3 'we need this to avoid the crash of program
End Sub
and if we want to let working this code we can:
use DataCount as SHARED variable
or
use DataCount as parameter of SUB Recur
or
use DataCount as STATIC variable of SUB Recur
or
use SUB Recur STATIC
....
at yours the choice
in this case you'll get twice the first 7 data from the file.
If you want to get also the second set of 7 data from the file, you need REMming SEEK #1,1.