Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Various code questions
#3
Let me answer these for you, as they all seem fairly straightforward.

1) & is the type symbol for LONG.  ~ is the type symbol for UNSIGNED.  So variable~&(1) is an array of _UNSIGNED LONG type, and you're referencing the first element in it.  

2) The : here is simply syntax for a multi-line statement.  It's basically counted the same as a new line.   For example:

x = 1: y = 2 

The above would be the exact same as: 

x = 1 
y = 2

You're just putting the 2 statements on the same line to reduce "code sprawl" and scrolling.  You'll see the use of : a lot when dealing with pixel coordinates and such, where it just makes sense to keep the two variables together as much as possible.

As for the loop:

DO
    _LIMIT 10
LOOP

This is simply a limit on the number of times that the loop can run in a second.  The limit here says, "Don't run the loop more than 10 times per second", so you're freeing up resources and not running a high CPU usage while just waiting for the user to press a key.

...  UNTIL  LEN(INKEY$) -- The LEN statement is to determine the LENGTH of something.  In INKEY$, the result it returns is going to be "" (a set of quotes with nothing between them), which would have a length of 0 characters/bytes.  When the user presses any key, INKEY$ would record the key pressed (Say "A" if you hit the A key), and the length would no longer be zero.

LOOP UNTIL LEN(INKEY$) says to basically repeat the loop until the user hits some key.   In combination with the rest of the code here, it says to just repeat the loop a maximum of 10 times per second, and wait for the user to press a key.  It's a CPU efficient pause in the program -- nothing more complex than that!  Wink
Reply


Messages In This Thread
Various code questions - by james2464 - 08-17-2022, 01:57 PM
RE: Various code questions - by mnrvovrfc - 08-17-2022, 02:09 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 02:09 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 02:13 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 02:21 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 02:30 PM
RE: Various code questions - by OldMoses - 08-17-2022, 04:55 PM
RE: Various code questions - by james2464 - 08-17-2022, 06:30 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 06:35 PM
RE: Various code questions - by james2464 - 08-17-2022, 06:43 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 06:53 PM
RE: Various code questions - by Kernelpanic - 08-17-2022, 08:32 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 09:25 PM
RE: Various code questions - by Kernelpanic - 08-18-2022, 01:31 PM



Users browsing this thread: 4 Guest(s)