Skip to content

The Set Statement

Raph Hennessy edited this page Nov 21, 2015 · 1 revision

After Q PL version 0.02 where almost everything was done using the define statement, I rethought how Q PL could be used and how the syntax could work. In Q PL 0.03, the syntax is almost completely redone with many new features. One of these is the new set statement. This page will have some information about what it is and how to use it.

Much like the name implies, the set statement in Q PL is used to set variables to a new value. If you want to create a variable, however, set currently cannot be used. When creating a variable, you must use the make statement. An example of the set statement in use is below

set language = 'q';

As you can see, the set syntax is very simple when you are only using it for basic tasks. You simply need to specify the name of the variable you want to change the value of and the new value. If you want to give it a numeric value, you can use something like the syntax below.

set myInt = 1;

You can also use the set statement to preform basic calculations such as in the examples below.

set math1 = 1+1;
set math2 = 3-2+1-3;
set math3 = math1*math2;
set math4 = math1/math3+math2-math3;

Although this may seem simple and limited, you can modulus, division and many other things inside a set statement to have complete control over what you want your variable to be set to. However when using set you need to remember as stated at the start of this document that you must have already created the variable you are changing, using make.

Clone this wiki locally