QUICK Tutorial Part 1 - By Dean Garraghty
(c)1994 Dean Garraghty
This is the first in a series of tutorials I have written to help
people get to grips with the QUICK programming language from Germany.
If you haven't heard of QUICK yet, then you must have been living on
the moon! If you don't know what it is, then I'll tell you now.
QUICK is a very powerful programming language from Germany. It is a
procedural language with many features from C, PASCAL, and Basic. It
also has unique commands to take advantage of the Atari's facilities,
including PMG control, mouse control, and even support for interrupts!
It is available directly from us (DGS): www.dgs.clara.net
OK, on with the tutorial! One thing many Basic programmers would have
thought when they got QUICK was "where the heck is the FOR...NEXT
loop?". Well, the FOR...NEXT structure is unique to Basic, and all
procedural languages (such as QUICK, C, PASCAL, ADA) use different
types of structures. However, with a bit of thought, you can simulate a
FOR...NEXT loop in QUICK. In fact there is at least two ways to do it!
First of all consider this Basic code:
10 FOR X=1 TO 10
20 PRINT X
30 NEXT X
As you will know, this code would print the numbers 1 to 10 on the
screen. Now consider the following QUICK code:
BYTE
[
X
]
MAIN
X=1
REPEAT
PRINT(X)
X+
UNTIL X=11
ENDMAIN
This code will do exactly the same as the Basic program, but a heck of
a lot faster! You will notice that it is very different to the Basic
program.
First of all, we have to declare the variable X as a BYTE. In QUICK we
must specify which variables we are going to use, and what sort of
variable they are before we start our program. In Basic, you don't have
to do this.
All the code in-between the MAIN and ENDMAIN is the actual program.
First of all we have to give X a value. I have used 1 here because we
want to print the numbers 1 to 10. The way to solve our FOR...NEXT
problem is to think about what is actually being done. Basically, the
FOR...NEXT is a loop which automatically increments its variable while
looping. It also does its own checking to stop when the variable
reaches its upper range (in our Basic example, when X reaches 11 it
will stop). Now that we know what the FOR...NEXT is actually doing, we
can attempt to write QUICK code to do the same.
One looping structure in QUICK is the REPEAT...UNTIL. Whatever code is
contained in-between the REPEAT and UNTIL will be repeated until a
certain condition is met. In our case, when X becomes equal to 11. All
we need to do now is actually print the value of X using PRINT(X) and
to increment the value of X ourselves. QUICK has a very nice way of
doing this. X+ will add one to the value of X. And that's how we do it
in QUICK!
One other way to do it, is to use the WHILE...WEND looping structure.
This is similar to the REPEAT...UNTIL, but the condition check is done
before the code in-between is executed. Consider this code:
BYTE
[
X
]
MAIN
X=1
WHILE X<11
PRINT(X)
X+
WEND
ENDMAIN
Here we are saying that while the value of X is less than 11, we should
execute all the code up to WEND. Oh yes, WEND is short for While END!
And there we are, two ways to implement a FOR...NEXT loop in QUICK.
Originally published in The Atari 8-bit News-Paper.
Click here to Return to the Articles Main Menu