It is currently Wed Sep 18, 2019 2:04 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: keyboardpushed(#PB_Any_Letter)
PostPosted: Thu Jun 20, 2019 10:04 pm 
Offline
User
User
User avatar

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 62
Location: Netherlands
When i put in a code e.g.
Code:
TheKey = KeyboardPushed(#PB_Key_RightAlt)

The result is 128 and not 1 if key is pressed.

The description say non zero. And the bottum line say 1 if key is pressed.
In bitwize notation 128 is bit number 7. and not bit number 0.

Was this a intention or is there something wrong here ?

_________________
From my first self made computer till now I stil like computers.


Top
 Profile  
Reply with quote  
 Post subject: Re: keyboardpushed(#PB_Any_Letter)
PostPosted: Thu Jun 20, 2019 11:58 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 262
I don't know what "bottom line" you're talking about, but the manual says: "Nonzero if the specified key is pushed, zero otherwise."

So, as Metallica says: nothing else matters. Test for zero or non-zero only to make it work as documented and intended.


Top
 Profile  
Reply with quote  
 Post subject: Re: keyboardpushed(#PB_Any_Letter)
PostPosted: Sun Jun 23, 2019 7:03 pm 
Offline
User
User
User avatar

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 62
Location: Netherlands
Sorry i was under the impression that i already replyed.

When you are in the IDE and type in
KeyboardPushed(...
You see at the bottom line the short explenation of using the function.
And that says: KeyboardPushed(KeyID) Returns a 1 if the assinged key is pressed. otherwise 0.

So you may think that the pressing of the key, gives you a 1 like #True. But i got a 128 value returned.
That put me on the wrong foot. When i try to write some code and you see the bottom line. you make up the wrong code.

Now i know that the last bit is set and not the first i can work with that. Every key give back a 128 value (Bit#7 is a 1). This is easy to convert to a 1 value (Bit #0 is a 1)
By making a procedure testing the key and give back the value i need.

Thanks guy's

_________________
From my first self made computer till now I stil like computers.


Top
 Profile  
Reply with quote  
 Post subject: Re: keyboardpushed(#PB_Any_Letter)
PostPosted: Sun Jun 23, 2019 7:23 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Jul 23, 2011 1:13 am
Posts: 215
Location: Germany
True. The quick-tip in the IDE differs from the help file.
Case for bugs: Documentation viewforum.php?f=37

I posted the mistake: viewtopic.php?f=37&t=73080


Top
 Profile  
Reply with quote  
 Post subject: Re: keyboardpushed(#PB_Any_Letter)
PostPosted: Mon Jun 24, 2019 12:02 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 262
bfernhout wrote:
You see at the bottom line the short explenation of using the function.
And that says: KeyboardPushed(KeyID) Returns a 1 if the assinged key is pressed. otherwise 0.

Oh, bottom line = status bar of the IDE. Yes, it says something different to the Help. Now I get what you mean.


Top
 Profile  
Reply with quote  
 Post subject: Re: keyboardpushed(#PB_Any_Letter)
PostPosted: Tue Jul 16, 2019 9:16 am 
Offline
User
User
User avatar

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 62
Location: Netherlands
Thanks for the post.
It is something that can bring new people on the wrong foot.

Still this is the best way to make programs. If I make the same program in C++, then they are alway larger and slower. I talk about say Purebasic run a program on 300 ms and the compiled and optimized c++ runs on a avarage of 380 ms.
Only when i make the program in Assembler the compiling create a smaller program and run faster.

But then again PB is beter and easyer to program.

_________________
From my first self made computer till now I stil like computers.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 18 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