More printing from DataSection

Advanced game related topics
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

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
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
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
Hi 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
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

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
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

This is deninetely a bug, and you should be able to read data from Procedure. I will take a look and fix it ASAP. Thanks !

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

As far as I remember it's the same with structures.
If you have a structure inside a procedure you can't use the structure for a 'outside' variable.




Have a nice day...
Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Bug found and eradicated :)

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cfriedel.

Sorry to reply so late (Thanksgiving in America =) ). Thanks for the fix. Hope to see it 2.70! [=)]

Cliff
Post Reply