Getting Started

From GAB Help
Revision as of 17:14, 10 October 2016 by GAB Bot (talk | contribs) (Import)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Programming can be a little intimidating if you've never done it before, but like almost anything else it isn't an all-or-nothing venture. Programs that perform useful functions in Global Shop can be as short as a few lines. Generally speaking, if you can write out a process step-by-step in plain English or Spanish (also called pseudo-code), writing the program isn't difficult.

Time for something simple:


function.intrinsic.UI.inputbox("What is your name?","Getting info",0,variable.local.result)


Variable.local.result would return whatever the user entered into the input box. Then the message box would display that variable.

Variables are used in programming languages to temporarily hold values. The first line declares (creates) a LOCAL variable named "RESULT". The portion that reads "STRING" indicates the type of data the variable will be asked to hold. Valid types are as follows:

Boolean - This variable type holds either a True or False

Date - This variable type holds date or time information

Float - This variable type holds numeric information (decimal)

Long - This variable type holds numeric information (whole numbers)

String - This variable type holds text information

Using the proper variable types is important, because the declaration lets GTL know what operations are legal when handling the variable. For example, date commands work with DATE type variables, while MATH commands work with FLOAT and LONG variables.

Please note that all PASSED variables are declared as STRING.

The INPUTBOX function prompts the user for typed input; when the input is received, it stores this into the LOCAL.RESULT variable.

The MSGBOX function displays text in a dialog box. In this example, the passed text is the contents of the LOCAL.RESULT variable.

The Next Step...

The sample program in the last section accepted input, stored it to a variable, then displayed the contents of the variable. We can take it a step further and accept data from the calling program instead.





This example takes the order date from the sales order entry screen, adds two days to the value, then places the new date into the due date field.

Conditional Processing

The last example allowed us to react to data passed from a Global Shop program, and populate a screen value with a calculated result. Automatic due date filling based on rules is something POS customers are accustomed to doing. The above code might not be desirable if there is already a due date present. Below is a pseudo-code example:

If something is true

then do this.....

and this...

and this

If something else is true

then do this.....

and this...

and this

If none of the previous conditions were true

then do this.....

and this...

and this

GTL handles this as an IF/ELSEIF/ELSE/ENDIF construction. Here's an example building on our existing code:







The “=” in the example above is called the operator. Valid operators are:

"=", "IS", "<>", "!=", "=!", "NOT", ">", "<", ">=", "=>", "<=", "=<"

The GAB documentation explains the use of these operators. Please note that several operators are functionally identical.

More Conditional Processing: From Code That Works to Code That Doesn't Break

With two lines of code, we were able to restrict the due date manipulation to orders that had no due date. Conditional structures are used extensively in good code to handle instances where the proper data is not passed. For example, if the order date (for whatever reason) is blank, the code above will blow up. Adding another condition to check for this possibility will make the code more robust.









This example features nested IF statements. Put another way, the IF statements are “layered”, so the second IF statement is evaluated only if the first IF statement was found to be true.


While control structures are the most important part of a programming language, the ability to loop is a close second. If you need to evaluate more than a single piece of data (perhaps for data aggregation), you will need to have the ability to evaluate each piece of information. Looping is the means by which you tell the computer to look at each item in order.

If you know how many times you want to loop (ex. number of months in a year), you can use a FOR loop. A FOR loop requires a control variable (usually a LOCAL variable declared as a LONG). Below is a pseudo-code example:

for i = 1 to number of days in the month

add up the labor hours for day i

store the result of the sum in a bucket for day i

next i

If you aren't sure how many times you need to loop (ex. traversing a set of database records), you can use a DO loop. Below is a pseudo-code example:


act on the next piece of data

if some condition is met, exit the loop


Loops, like conditional statements, can be nested for multiple levels of looping. A common example of this may be processing all of the days in a month, for each month of a year, for all of your workcenters individually – that would be three nested loops.

Making the Example More Practical Through Looping

The example we've been building seems pretty straightforward, and looping may not appear to be necessary on the surface. Digging a bit deeper into the usage, however, reveals weaknesses. What if the order is taken on a Thursday? In that case, the order will be due on a Saturday. Let's fix it:


















GAB Line Layout

Syntax arguments


Identifier - Function, GUI, Program, or Variable

SubIdentifier -

Nominative - Name variable or name of variable with array, screen and screen element. Delimited by !

Property/Method -

Arguments -


Function.Intrinsic.txtA.declare (args)


Comments - Adding comments to your code allows anyone to go into your code and be able to figure out what the code is supposed to do in each section. To add a comment simple put a ‘ in front of the comment, the line should turn green in the Editor. No in-line comments are allowed.

Comments can be used for:

  • Showing a modification user log
  • Showing a Change Log
  • Explaining what the code is supposed to do

Indention – Using indentation with control structures (“if” blocks and loops) helps with readability. Use continued indention for each subsequent control block.

‘Outer If


‘Inner If


   ‘Stuff to do inside the if statement
   Function.Intrinsic.ui.Msgbox("There is no cost","",0)
   ‘Ends the program/project

‘Ends the Inner If


‘Ends the Outer If



V.AMBIENT. = Variable.Ambient.

V.ARGS. = Variable.Args.

V.CALLER. = Variable.Caller.

V.COLOR. = Variable.Color.

V.EXTERNAL. = Variable.External.

V.GLOBAL. = Variable.Global.

V.LOCAL. = Variable.Local.

V.ODBC. = Variable.ODBC.

V.PASSED. = Variable.Passed.

V.SCREEN. = Variable.Screen.

V.STATIC. = Variable.Static.

F.AUTOMATION. = Function.Automation.

F.COMMUNICATION. = Function.Communication.

F.INTRINSIC. = Function.Intrinsic.

F.GLOBAL. = Function.Global.

F.ODBC. = Function.ODBC.

F.UNOFFICIAL. = Function.Unofficial.

P.SUB. = Program.Sub