G-Script V0.5 ( Delta X Software 1.2.5) will be updated soon 

G-Script V0.3 ( Delta X Software 0.9.5)

[Update 2020]

1. GOTO - Jumping Ahead in G-Code
GOTO is pretty simple to use, it’s just GOTO followed by the sequence number (“N” number) you’d like to jump to.

For example:

That program snippet uses a GOTO whose address is “15” to jump over N10 and go directly to N15.
2. Conditional Expressions
Let’s talk about the rules for Conditional Expressions.  
Here are the rules: 
    - Conditional expressions must be enclosed in square brackets (“[” and “]”). 
    - A Conditional Expression consists of two operands and a comparison operator. 
    - An operand may be a # variable or a number. 
    - There must be a space between a comparison operator and operands. 
    - Comparison Operators:  
        EQ : Equal
        == : Equal 

        NE : Not equal 
        != : Not equal 

        GT : Greater than 
        > : Greater than 

        GE : Greater than or equal 
        >= : Greater than or equal 

        LT : Less than
        < : Less than

        LE : Less than or equal
        <= : Less than or equal

Comparisons may be further grouped with square brackets and AND, OR, or XOR. For example:

[[0 LE #100] AND [#100 LE 1000]] 
[[0 < #100AND [#100 > 1000]] (True if the value of #100 is 0 to 1000) 

3. IF - Conditional Branching
While GOTO represents an “unconditional branch” in G-Code execution, IF allows for “conditional branching”. 
Syntax of IF statement: IF [Conditional Expression] THEN <do somethings> 
    - If Conditional Expression is true, the G-code will execute the command behind THEN. 
    - If Conditional Expression is false, the G-code falls through to the next line. 

For example:

In the above example, the line of code N70 uses the IF statement. The conditional expression here is: #100 LE 2 

If the variable #100 is still less than or equal to 2, the program will jump to line N20 and execute the code from there. 

At line 60, variable #100 will increase by one unit. The job will be repeated like this until the variable #100 is greater than 2. Then, the conditional expression in the if statement is wrong and the program will not execute the GOTO 20 instruction, but automatically execute the next line of code N80 G01 X0 Y0 and terminate the program.

4. Variables
They can be assigned values, and its value could be changed during program execution. When you refer to them, they give back the last value they were assigned. 

The syntax for a variable is the pound sign followed by a number up to however many digits your controller supports that identifies the variable. 

For example, we can write “#100 = 0” to assign the value “0” to the variable “#100”.

- Global variable: When a variable is prefixed with #GLOBAL like #GLOBAL_IsRunning, the program of other robots in the project will be able to use that variable.

- System variables:
#X#Y#Z#W#U#V - Robot's position

#F, #A, #S, #E  - Robot's constant speed, acceleration, start speed and end speed

#ConveyorSpeed#ConveyorDirection - Speed and direction of conveyor

#O0_X, #O0_Y, #O0_Z, #O0_W, #O0_H - The position and size of the first object detected by the camera.

#O[id]_X, #O[id]_Y, #O[id]_Z, #O[id]_W, #O[id]_H - [id] is the order in which the object appears. If the object is deleted, it will have a NULL value.

IF [#O0_X != NULL] THEN G01 X[#O0_X]

- Robot Input:
#Response - The string is sent from the robot to the software
#I[id] - State of input, [id] is order of pin

Software >> G28
Robot >> Ok ----> #Response = "Ok"
Software >> M7 I0
Robot >> I0 V1 ----> #Response = "I0 V1", #I0 = 1
Software >> M7 I4
Robot >> I4 V0 ----> #Response = "I4 V0",  #I4 = 0

5. Subprograms
a. Define the subprogram 

The syntax to start a subprogram with the letter ‘O’ followed by a number. This number is the name of the subprogram. 

As the example above, line 20 is the start of a subprogram named 1000. And then, we start programing for the subprogram (from line 30 to 55). To end the subprogram, we use M99 command (line 65). 

b. Call the subprogram 

To call the subprogram, we use the syntax: M98 P<name of the subprogram> 

For example: 

6. Execute another G-code file
M98 FExample ( "Example" is the name of G-code file)

[index]7. Function[/index]

- Object Detecting

M98 PpauseCamera - Pause reading frames from the camera

M98 PresumeCamera - Resume reading camera

M98 PcaptureCamera - Capture a frame from camera

M98 PdeleteFirstObject - Delete the first element in the container of the tracking objects

M98 PclearObjects - Clear all tracking objects in container

Object Detecting

M98 PsyncConveyor - Synchronize the robot with the conveyor

M98 PstopSyncConveyor - Stop syncing the robot with the conveyor

- Communicate

M98 PsendExternalMCU - Send a string to the external microcontroller that is connecting to the software.

M98 PsendExternalMCU("Hello World")

Math Methods
#sin([value]) - Compute sine (value is degree)
#cos([value]) - Compute cosine (value is degree)
#cos([value]) - Compute cosine (value is degree)
#tan([value]) - Compute tangent (value is degree)
#asin([value]) - Compute arc sine(result is degree)
#atan([value]) - Compute arc tangent (result is degree)
#atan2(x, y) - Compute arc tangent with two parameters (result is degree)
#abs([value]) - Compute absolute value
#sqrt([value]) - Compute square root
#pow([value1],[value2]) - Raise to power, ex: #result = #pow(2,3) -----> #result = 8