I'm having trouble getting this function to work in my program. What it's SUPPOSED to do is read all the lines in a text file, and place them on the screen, in a message window, 4 lines at a time. When you press a key, it goes to the next 4 lines, until there is no text left. I'm using a text file with 5 lines and it skips the first four, instead of waiting for you to press a key. I'm using Blitz Plus, but without ANY actual blitz plus commands, so it SHOULD act like its a blitz basic game. Here's the code:
I know it's not the best or cleanest code, but I'm still new at this (hence the reason this is in the beginner's section lol).
Function MWin(file$) Color tr,tg,tb crap$="progs"+file$+".txt" file$=crap$ filein=ReadFile(file$) num=0 While Not Eof(filein) sline.someline=New someline sline\aline$=ReadLine$(filein) sline\index=num+1 Wend CloseFile(filein) placemwin=Int(reswidth/2)-160 .mwinagain For sline.someline=Each someline If sline\index=1 Then line1$=sline\aline$ EndIf If sline\index=2 Then line2$=sline\aline$ EndIf If sline\index=3 Then line3$=sline\aline$ EndIf If sline\index=4 Then line4$=sline\aline$ EndIf Delete sline Next RenderGraphics() DrawImage mwin,placemwin,0 Text placemwin+5,5,line1$ Text placemwin+5,20,line2$ Text placemwin+5,35,line3$ Text placemwin+5,50,line4$ Flip FlushKeys() WaitKey() linenum=0 For sline.someline=Each someline linenum=linenum+1 sline\index=sline\index-4 Next If linenum>0 Then Goto mwinagain End Function
I know it's not the best or cleanest code, but I'm still new at this (hence the reason this is in the beginner's section lol).