It is currently Sun Sep 22, 2019 1:15 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject:
PostPosted: Mon Aug 19, 2002 10:01 am 
Offline
PureBasic Guru
PureBasic Guru

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

I have the following code:

call the checkcommand() from the thread doesn't work.
It doesn't fire up.

What am I doing wrong?

Code:
 
CreateThread(@ScanKeysThread(), 100)
;
;
Procedure ScanKeysThread()
com$=""
Repeat
  c=GetKey() ; Pause app until a key has been pressed.
  If c  32 ; space pressed
   com$=com$+Chr(c)
   Else
    MessageRequester("",com$,0)   ; This works
    checkcommand() ; this doesn't work
    com$=""
  EndIf
Until ForEver ; Loop forver
EndProcedure
;
Procedure checkcommand()
  MessageRequester("",com$,0)
EndProcedure


Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 19, 2002 10:31 am 
Offline
PureBasic Guru
PureBasic Guru

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

Try changing the order of your routines so that each section is referencing
something that has been declared. At the moment, the thread is calling a
procedure that hasn't been declared yet, which is probably the problem.
I say "probably" because I'm not 100% sure as I don't use threads yet.

So, change your code to this:

Code:
; Declare this procedure first so ScanKeysThread knows about it.
Procedure checkcommand()
  MessageRequester("",com$,0)
EndProcedure
;
Procedure ScanKeysThread()
com$=""
Repeat
  c=GetKey() ; Pause app until a key has been pressed.
  If c  32 ; space pressed
   com$=com$+Chr(c)
   Else
    MessageRequester("",com$,0)   ; This works
    checkcommand() ; this doesn't work
    com$=""
  EndIf
ForEver ; *** Changed from "Until ForEver" because "Until" isn't needed ***
EndProcedure
;
; Do this last so it knows about the ScanKeysThread procedure.
CreateThread(@ScanKeysThread(), 100)



PB - Registered PureBasic Coder


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 19, 2002 11:16 am 
Offline
PureBasic Guru
PureBasic Guru

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

Order of procedures doesn't matter.

All procedures are declared.

Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 19, 2002 11:35 am 
Offline
PureBasic Guru
PureBasic Guru

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

Your variable isnt SHARED...

Code:
Procedure checkcommand()
Shared com$
  MessageRequester("",com$,0)
EndProcedure
 
 
Procedure ScanKeysThread()
Shared com$
com$ = "TEST"
    checkcommand() ; this doesn't work
EndProcedure
 
 
CreateThread(@ScanKeysThread(), 100)
 
Delay(10000)


cya,
...Danilo

(registered PureBasic user)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 19, 2002 11:46 am 
Offline
PureBasic Guru
PureBasic Guru

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

> Your variable isnt SHARED...

That wouldn't matter though... the MessageRequester would just show an empty
string. Cor, do you mean that the MessageRequester is never showing up in
the CheckCommand() procedure? That's what I understand the problem to be?


PB - Registered PureBasic Coder


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: blueb and 4 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