It is currently Thu Jul 02, 2020 8:33 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject:
PostPosted: Tue Nov 20, 2001 5:47 am 
Offline
PureBasic Guru
PureBasic Guru

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 20, 2001 11:34 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Pupil.

Quote:
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 20, 2001 5:29 pm 
Offline
PureBasic Guru
PureBasic Guru

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 20, 2001 9:46 pm 
Offline
PureBasic Guru
PureBasic Guru

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 20, 2001 10:17 pm 
Offline
PureBasic Guru
PureBasic Guru

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Nov 21, 2001 1:38 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by fred.

Bug found and eradicated :)

Fred - AlphaSND


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Nov 26, 2001 4:03 pm 
Offline
PureBasic Guru
PureBasic Guru

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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye