LOGO-L> Re: Keyboard commands 
Author Message
 LOGO-L> Re: Keyboard commands

Where do the numbers -72 -77 -80 and -75 come from?


Quote:

>Hello Ruth,
>The problem you mentioned is solved in our Logo-version Superlogo (Europe)
>by the following 2 procedures:

>to move
>setphase phase + 1
>forward 10 wait 100
> if key? [which.key][move]
>move
>end

>to which.key
>make "pushed readkey
> if :pushed = -72 [setheading 0]
>if :pushed = -77 [setheading 90]
> if :pushed = -80 [setheading 180]
> if :pushed = -75 [setheading 270]
>end

[snip]
================================
Michael Tempel
Logo Foundation
250 West 85th Street
New York NY 10024
phone: 212 579 8028
fax: 212 579 8013
http://www.*-*-*.com/
---------------------------------------------------------------





Thu, 26 Sep 2002 03:00:00 GMT  
 LOGO-L> Re: Keyboard commands
I think they are the equivalent of the ascii-numbers; it is certainly
workable in our SUPERLOGO-version
if (ascii :key) = 37 [ seth 270]>in Superlogo... if :pushed = -75
[setheading 270]

if (ascii :key) = 39 [ seth 90] >in Superlogo...if :pushed = -77 [setheading
90]

if (ascii :key) = 38 [ seth 0] > in Superlogo...if :pushed = -72 [setheading
0]

if (ascii :key) = 40 [ seth 180]>in Superlogo ... if :pushed = -80
[setheading 180]



Quote:
> Where do the numbers -72 -77 -80 and -75 come from?


> >Hello Ruth,
> >The problem you mentioned is solved in our Logo-version Superlogo
(Europe)
> >by the following 2 procedures:

> >to move
> >setphase phase + 1
> >forward 10 wait 100
> > if key? [which.key][move]
> >move
> >end

> >to which.key
> >make "pushed readkey
> > if :pushed = -72 [setheading 0]
> >if :pushed = -77 [setheading 90]
> > if :pushed = -80 [setheading 180]
> > if :pushed = -75 [setheading 270]
> >end

> [snip]
> ================================
> Michael Tempel
> Logo Foundation
> 250 West 85th Street
> New York NY 10024
> phone: 212 579 8028
> fax: 212 579 8013
> http://www.logofoundation.org/
> ---------------------------------------------------------------






Thu, 26 Sep 2002 03:00:00 GMT  
 LOGO-L> Re: Keyboard commands

Quote:
>Where do the numbers -72 -77 -80 and -75 come from?

Michael,

The numbers are returned by readkey function. To an unexperienced user I
would say that they are "a kind of magic technical numbers", and that there
is no reason to ask just as there is no reason to ask why in Microworlds
the numbers are 37, 39, 38 and 40 (ascii codes of characters returned by
readchar when pressing arrow keys).

The more technical answer is that 72, 77, 80 and 75 are codes of arrow keys
returned in AH by BIOS interrupt 16H when AL=0 (also known as "extended
ascii keystrokes").
And the minus sign is used to distinguish the "special" codes from codes of
keys, which generate a "usual" ascii code (readkey returns an acii code if
you press a "usual" key).
So you can see that we started to develop SuperLogo in DOS and converted
just later to Windows.

I have a similar question for MicroWorlds:
Why readchar uses codes 37, 39, 38 and 40 for arrow keys if the same codes
are generated also by other keys?

I understand that the numbers 37, 39, 38 and 40 come from vk_xxxx codes
sent as a part of wm_keydown messages.
But the same codes are also returned by other keys (by characters having
characters with ascii codes 37..40, which are % & ' ( ). On the technical
Win32API level these codes are part of wm_char messages.
For example readchar returns the same value (38) if you press the up arrow
and also if you press the & sign on the keyboard (Shift+7 on U.S. keyboard).
Is there any way to distinguish these two keys in MicroWorlds? If not then
do you (or somebody else) know, why this approach was used?

Regards

Peter Tomcsanyi

---------------------------------------------------------------





Thu, 26 Sep 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. LOGO-L> Keyboard commands

2. LOGO-L> Logo commands

3. LOGO-L> keyboard size

4. LOGO-L> bury command in MSWlogo

5. LOGO-L> Re: Shut Down Command

6. Apple Logo II > Fill Command

7. LOGO-L> Re: Using Command Line Options

8. LOGO-L> Re: Using Command Line Options

9. LOGO-L> Using Command Line Options

10. LOGO-L> erase command

11. LOGO-L> Apple logo/MSW Logo

 

 
Powered by phpBB® Forum Software