|
Post by stan58 on May 19, 2023 6:30:20 GMT -5
The user inputs data into a text editor, I then want to read each line as follows
print #first.data, "!line 1 check$" ; this works fine but I want to index each line as follows
count=1 print #first.data, "!line (count) check$" ; this doesn't work, I would of course increment the count variable and repeat until all lines are done but check$ has no data
|
|
|
Post by metro on May 19, 2023 7:39:45 GMT -5
see if this helps, thanks to Anatoly, I fixed my issue which was similar.(brain fog @68 can be contagious)
'Form created with the help of Freeform 3 v07-15-08 'Generated on Nov 30, 2018 at 16:20:26 global NumLines , z 'nomainwin LotsOflines$(1)="A segmentation fault (aka segfault) is a common condition that causes programs to crash; they are often associated with a file named core. " LotsOflines$(2)="Segfaults are caused by a program trying to read or write an illegal memory location. Program memory is divided into different segments: a text segment for program instructions, " LotsOflines$(3)="a data segment for variables and arrays defined at compile time, a stack segment for temporary (or automatic) variables defined in subroutines and functions, " LotsOflines$(4)="and a heap segment for variables allocated during runtime by functions, such as malloc (in C) and allocate (in Fortran). For more, see What are program segments," LotsOflines$(5)=" and which segments are different types of variables stored in? A segfault occurs when a reference to a variable falls outside the segment where that variable resides, " LotsOflines$(6)="or when a write is attempted to a location that is in a read-only segment. In practice, segfaults are almost always due to trying to read or write a non-existent array element," LotsOflines$(7)="not properly defining a pointer before using it, or (in C programs) accidentally using a variable's value as an address (see the scanf example below):"
[setup.main.Window]
'-----Begin code for #main
' nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
TexteditorColor$ = "white" texteditor #main.tex3, 5, 5, 530, 100 button #main.button1,"TOP",[button1Click], UL, 320, 150, 38, 25 button #main.button2,"BOTTOM",[button2Click], UL,370, 150, 68, 25 '-----End GUI objects code
'-----Begin menu code menu #main, "Edit" ' <-- Texteditor menu. '-----End menu code
open "untitled" for window as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit.main]"
[main.inputLoop] 'wait here for input event
for a = 1 to 7 #main.tex3, LotsOflines$(a) next
'=============================================================== [GET.LINES.BACK] '============================================================== 'DIM remittance$(100000) #main.tex3 ,"!lines LineCount" ; 'print LineCount for z = 1 to LineCount print #main.tex3, "!line ";z;" recs$" print recs$ next
wait
[button1Click] 'Perform action for the button named 'button1' #main.textedit3, "!origin 1 1" ; wait
[button2Click] 'Perform action for the button named 'button2' call countlines #main.textedit3 , "!origin "; " 1 "; NumLines/2 ; ' print NumLines wait
[quit.main] 'End the program close #main end
sub countlines 'print #main.textedit3, "!origin? columnVar rowVar " ; print #main.textedit3, "!lines NumLines" ;
end sub
|
|
|
Post by stan58 on May 19, 2023 11:42:54 GMT -5
Thank you, metro guru. Sorted
|
|