Parameter Buffer Manipulation


The parameter buffer is a built-in data structure
that may be used if some values (coordinates, for example) change after a definite rule that can be described using a mathematical expression.
This is useful if, for instance, you want to store the current values of your variables.

https://gdl.graphisoft.com/wp-content/uploads/ac19-gdl/ControlStat_buffer_put.png

The parameter buffer is an infinitely long array in which you can store numeric values using the PUT command.
PUT stores the given values at the end of the buffer.
These values can later be used (by the GET and USE commands) in the order in which they were entered
(i.e., the first stored value will be the first one used).
A GET(n) or USE(n) command is equivalent with n values separated by commas.
This way, they can be used in any GDL parameter list where n values are needed.

https://gdl.graphisoft.com/wp-content/uploads/ac19-gdl/ControlStat_buffer_get.png
https://gdl.graphisoft.com/wp-content/uploads/ac19-gdl/ControlStat_buffer_use.png

PUT

PUT expression [, expression, ...]

Store the given values in the given order in the internal parameter buffer.

GET

GET (n)

Use the next n values from the internal parameter buffer and then disregard them.

USE

USE (n)

Use the next n values from the internal parameter buffer without deleting them.
Following USE and GET functions can use the same parameter sequence.

NSP

NSP

Returns the number of stored parameters in the internal buffer.

Example:
Using the parameter buffer:

https://gdl.graphisoft.com/wp-content/uploads/ac19-gdl/ControlStat_buffer_ex.png
r = 2
b = 6
c = 4
d = 10
n = 12
s = 180 / n
FOR t = 0 TO 180 STEP s
    PUT r+r*COS(T), c-r*SIN(t), 1
NEXT t
FOR i = 1 TO 2
    EXTRUDE 3+NSP/3, 0,0,d, 1+16,
            0, b, 0,
            2*r, b, 0,
            USE(NSP),
            0, b, 0
    MULY -1
NEXT i
DEL 1
ADDZ d
REVOLVE 3+NSP/3, 180, 0,
        0, b, 0,
        2*r, b, 0,
        GET(NSP),
        0, b, 0

The full description:

r = 2
b = 6
c = 4
d = 10
FOR i = 1 TO 2
    EXTRUDE 16, 0,0,d, 1+16,
            0, b, 0,
            2*r, b, 0,
            2*r, c, 1,
            r+r*COS(15), c-r*SIN(15), 1,
            r+r*COS(30), c-r*SIN(30), 1,
            r+r*COS(45), c-r*SIN(45), 1,
            r+r*COS(60), c-r*SIN(50), 1,
            r+r*COS(75), c-r*SIN(75), 1,
            r+r*COS(90), c-r*SIN(90), 1,
            r+r*COS(105), c-r*SIN(105), 1,
            r+r*COS(120), c-r*SIN(120), 1,
            r+r*COS(135), c-r*SIN(135), 1,
            r+r*COS(150), c-r*SIN(150), 1,
            R+R*COS(165), c-r*SIN(165), 1,
            0, b, 1,
            0, b, 0
    MULY -1
NEXT i
DEL 1
ADDZ d
REVOLVE 16, 180, 0,
        0, b, 0,
        2*r, b, 0,
        2*r, c, 1,
        r+r*COS(15), c-r*SIN(15), 1,
        r+r*COS(30), c-r*SIN(30), 1,
        r+r*COS(45), c-r*SIN(45), 1,
        r+r*COS(60), c-r*SIN(50), 1,
        r+r*COS(75), c-r*SIN(75), 1,
        r+r*COS(90), c-r*SIN(90), 1,
        r+r*COS(105), c-r*SIN(105), 1,
        r+r*COS(120), c-r*SIN(120), 1,
        r+r*COS(135), c-r*SIN(135), 1,
        r+r*COS(150), c-r*SIN(150), 1,
        r+r*COS(165), c-r*SIN(165), 1,
        0, b, 1,
        0, b, 0