Restored from previous forum. Originally posted by cfriedel.
Having some trouble with a program I am trying to write. For some reason, this procedure will not keep reading from the data. Instead it just types the first line ("This is") over and over. The code is listed below. Can somebody please tell me why this is happening. Thanks for all the help. Sorry if I sound frustrated.
Cliff
Procedure missionpage()
LoadSound(0,"Sounds\typewriter.wav")
ClearScreen(64,64,64)
FlipBuffers()
ClearScreen(64,64,64)
Restore DAT_MissionText
For y = 0 To 3
z = 1
Read text$
While z <= Len(text$)
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawingFont(font1)
FrontColour(255,255,255)
Locate((z*8)-8,y*12)
DrawText(Mid(text$,z,1))
StopDrawing()
FlipBuffers()
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawingFont(font1)
FrontColour(255,255,255)
Locate((z*8)-8,y*12)
DrawText(Mid(text$,z,1))
StopDrawing()
FlipBuffers()
PlaySound(0)
Delay(100)
z = z + 1
Wend
Next
Delay(2000)
FreeSound(0)
ProcedureReturn 0
EndProcedure
DataSection
DAT_MissionText:
Data$ "This is"
Data$ "a test"
Data$ "to write text"
Data$ "to the graphics screen"
EndDataSection
More printing from DataSection
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
yes there is a problem with reading data from within a procedure all will work fine if you move the code outside the procedure and do a gosub instead i.e:
... ; maincode
gosub missionpage
... ; maincode continues
end
missionpage:
... ; your missionpage code here
return ; return from this subroutine
I dont't know if this behaviour is intended i.e you should not read data from a procedure or if it's just a slip on Fred's side.
Good luck with your game!
/Pupil
Hi Cliff,Having some trouble with a program I am trying to write. For some reason, this procedure will not keep reading from the data. Instead it just types the first line ("This is") over and over. The code is listed below. Can somebody please tell me why this is happening. Thanks for all the help. Sorry if I sound frustrated.
Cliff
yes there is a problem with reading data from within a procedure all will work fine if you move the code outside the procedure and do a gosub instead i.e:
... ; maincode
gosub missionpage
... ; maincode continues
end
missionpage:
... ; your missionpage code here
return ; return from this subroutine
I dont't know if this behaviour is intended i.e you should not read data from a procedure or if it's just a slip on Fred's side.
Good luck with your game!
/Pupil
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by cfriedel.
Ok, changed the code to a gosub and it seems to work. Fred, is there a reason for not reading data from a procedure? Making subroutines instead of procedures makes it a little harder to pass variables and muddies the scope a little (not that I'm complaining ). Anyway, thanks for all of the help. With the new code I am beginning to make some progress. Maybe this time I will actually write some code that doesn't demolish my machine !
Cliff
Ok, changed the code to a gosub and it seems to work. Fred, is there a reason for not reading data from a procedure? Making subroutines instead of procedures makes it a little harder to pass variables and muddies the scope a little (not that I'm complaining ). Anyway, thanks for all of the help. With the new code I am beginning to make some progress. Maybe this time I will actually write some code that doesn't demolish my machine !
Cliff
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm