Restored from previous forum. Originally posted by devices.
Hi
whilst I still have some hair left, could someone please point me in the right direction.
I am trying to give values to a series of variables using a onscreen "keypad".
The codeing I think should go something like this:-
keypad:
If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30:a=1:c=1:EndIf
If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30:b=1:c=0:EndIf
Return
This is just an example.
I want to give a=1 on the first click of "ButtonGadget" 30 and b=1 on the next click.
However what I get is a=1 on the first click, but nothing on the second.
What am I doing wrong?
Thanks Richard
onscreen "keypad".
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30:a=1:c=1:EndIf
> If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30:b=1:c=0:EndIf
>
> I want to give a=1 on the first click of "ButtonGadget" 30 and b=1 on the next click.
> However what I get is a=1 on the first click, but nothing on the second.
That's because the second line (b=1) never gets seen because WaitWindowEvent is
called twice. I haven't tested it, but try an approach like this instead:
PB - Registered PureBasic Coder
> If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30:a=1:c=1:EndIf
> If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30:b=1:c=0:EndIf
>
> I want to give a=1 on the first click of "ButtonGadget" 30 and b=1 on the next click.
> However what I get is a=1 on the first click, but nothing on the second.
That's because the second line (b=1) never gets seen because WaitWindowEvent is
called twice. I haven't tested it, but try an approach like this instead:
Code: Select all
If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30
If a=0 : a=1 : c=1 : EndIf
If a=1 : b=1 : c=0 : EndIf
EndIf
PB - Registered PureBasic Coder
-
BackupUser
- PureBasic Guru

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

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

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

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> However this gives a=1 and b=1 on a single click!
Oops, my mistake (I didn't test it, as mentioned). Do this instead:
> Is there any rule as to how close together "WaitWindowEvents" can be in a sub group?
Each time WaitWindowEvent is called, it cancels the values of the previous call.
In other words, EventGadgetID in the second call is different to the first.
PB - Registered PureBasic Coder
> However this gives a=1 and b=1 on a single click!
Oops, my mistake (I didn't test it, as mentioned). Do this instead:
Code: Select all
If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30
If a=0
a=1 : c=1
ElseIf a=1
b=1 : c=0
EndIf
EndIf
Each time WaitWindowEvent is called, it cancels the values of the previous call.
In other words, EventGadgetID in the second call is different to the first.
PB - Registered PureBasic Coder