Pasteurized Arrowkeys

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Pasteurized Arrowkeys

Post by richmond62 » Mon Jun 10, 2019 8:51 am

I don't really want end-users from getting one response when they press on a key (i.e. no automatic repeats).

So, was a bit surprised why this:

Code: Select all

on arrowKey AK
   put item 1 of the loc of grc "rp" into LR
   put item 2 of the loc of grc "rp" into UD
   switch AK
      case "left"
         subtract 10 from LR
         move grc "rp" to LR,UD
         pass arrowKey
         break
      case "up"
         subtract 10 from UD
         move grc "rp" to LR,UD
         pass arrowKey
         break
      case "right"
         add 10 to LR
         move grc "rp" to LR,UD
         pass arrowKey
         break
      case "down"
         add 10 to UD
         move grc "rp" to LR,UD
         pass arrowKey
         break
   end switch
end arrowKey
Didn't stop that.

Possibly I have misunderstood the role of 'pass'.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Pasteurized Arrowkeys

Post by richmond62 » Mon Jun 10, 2019 9:01 am

And replacing 'pass arrowKey' with:

Code: Select all

flushEvents("all")
throws a 'bluey'.

Code: Select all

exit to top
is similarly useless.
Last edited by richmond62 on Mon Jun 10, 2019 9:38 am, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Pasteurized Arrowkeys

Post by richmond62 » Mon Jun 10, 2019 9:09 am

What I am looking for would be a bit like this (pseudoCode):

if arrowKeyStillDown then
end arrowKey
end if

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Pasteurized Arrowkeys

Post by jmburnod » Mon Jun 10, 2019 10:21 am

Hi Richmond,
What about this cd script ?

Code: Select all

local sStartTime
on opencard
   initStartime
end opencard

on initStartime
   put the milliseconds into sStartTime
end initStartime

on arrowkey pDir
   if the milliseconds < (sStartTime + 500) then
      beep
      exit arrowkey
   else
      put pDir & sStartTime into fld "fSpy"-- you have to create one fld "fSpy"
      put the milliseconds into sStartTime
   end if
end arrowkey
Best
Jean-Marc
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Pasteurized Arrowkeys

Post by richmond62 » Fri Jun 14, 2019 10:06 am

This didn't stop key repeats:

Code: Select all

on arrowKey AK
   put item 1 of the loc of img "bull" into LR
   put item 2 of the loc of img "bull" into UD
   if AK = "up" then
      subtract 8 from UD
      move img "bull" to LR, UD
      if intersect(img"bull",img"maze",5) then
          move img "bull" to 162,676
         end if
      exit to top
   end if
end arrowKey
This is slightly pathetic for the very, very simple
reason that I can do this on my BBC Model B from 1981:
-
Screen shot 2019-06-14 at 12.05.44 PM.png
Screen shot 2019-06-14 at 12.05.44 PM.png (7.63 KiB) Viewed 6820 times
Some wag made a rude remark about GOTO and GOSUB when they were introduced in BASIC
(much the same way as "clever" programmers are rude about LiveCode nowadays) . . .

Now, as LiveCode DOES have line numbers (go and look!), why is there no GOTO equivalent to
escape from a script?

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Pasteurized Arrowkeys

Post by Klaus » Fri Jun 14, 2019 10:15 am

richmond62 wrote:
Fri Jun 14, 2019 10:06 am
Now, as LiveCode DOES have line numbers (go and look!), why is there no GOTO equivalent to escape from a script?
This in just a feature of the Script Editor for our convenience.
The scripts do not have line numbers, at least the engine does not count them or support this.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Pasteurized Arrowkeys

Post by richmond62 » Fri Jun 14, 2019 10:43 am

The scripts do not have line numbers, at least the engine does not count them or support this.
In some ways that's a pity. :(

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Pasteurized Arrowkeys

Post by sphere » Fri Jun 14, 2019 12:30 pm

Oh man, i can remember the days (& nights) when i had my first MSX, typing over those listings in MSX-magazines, learning myself to type. MicroSoft Basic...and then euh where is the R, and euh where is the U and then after 2 minutes ah i found the N. Just great!

Then i had the great idea to steer my 4 color plotter with my joystick (which still worked after many hours Hyper Sports and such) andwith Fire i could change the color. It was useless further but it worked.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Pasteurized Arrowkeys

Post by richmond62 » Fri Jun 14, 2019 12:56 pm

Oh man, i can remember the days
Come Monday morning, and a good half dozen 10 year olds will be sitting down in front of my
BBC Micro computers for the simple reason that foetuses when they incubate in their mother's
wombs RECAPITULATE . . . 8)
-
beebem.png
beebem.png (23.72 KiB) Viewed 6782 times
-
Err . . . the theory of foetal recapitulation has been debunked . . . :evil:

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Pasteurized Arrowkeys

Post by Mikey » Fri Jun 14, 2019 2:30 pm

richmond62 wrote:
Fri Jun 14, 2019 10:43 am
The scripts do not have line numbers, at least the engine does not count them or support this.
In some ways that's a pity. :(
Structured languages that lack GOTO definitely make some things harder, but line numbers are not a good thing. Line labels seem to be a reasonable tool (even if they can make code harder to read in some cases).

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Pasteurized Arrowkeys

Post by richmond62 » Fri Jun 14, 2019 2:33 pm

Line labels
And how can one (can one?) implement those in LiveCode?

AND, HOW, more to the point . . .

. . . can one 'escape' a script?

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Pasteurized Arrowkeys

Post by Mikey » Fri Jun 14, 2019 2:37 pm

Why ctrl-alt-delete, of course

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Pasteurized Arrowkeys

Post by richmond62 » Fri Jun 14, 2019 4:12 pm

ctrl-alt-delete
is it possible to implement that programmatically?
Last edited by richmond62 on Fri Jun 14, 2019 5:13 pm, edited 1 time in total.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Pasteurized Arrowkeys

Post by jacque » Fri Jun 14, 2019 4:42 pm

Dar posted a workable solution to the mailing list. Generally if you need to exit a script, changing the structure will allow it.

If you really want to do it in a "goto" way, you can experiment with "exit to top" or "return".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”