Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Getting started: your first Program

A Program is the basic unit of business logic: it receives parameters, does something (reads/writes tables, computes, calls other programs) and finishes. It doesn’t have to show a screen or print anything.

1. Minimal file

@Documentation {
    Author Name : "Your Name"
}
@Properties {
    Type        : Program
    Name        : PGREET
    Description : "Minimal greeting program"
}
@References {
    Programs = []
    Screens  = []
    Tables   = []
}
@Variables {
    global {
        Username char(10)
        Greeting char(30)
    }
}
@Parameters {
}
@Source {
    &Username = USERID()
    &Greeting = "Hello, " + &Username
}

This is already a valid .warp file: it declares the object (@Properties), its variables (@Variables) and its logic (@Source). @References/@Parameters are empty because this program doesn’t depend on other objects or receive parameters.

2. Adding parameters

A Program receives parameters declared in @Parameters, referencing variables already declared in @Variables/global:

@Variables {
    global {
        MyDate  date
        MyTime  char(8)
    }
}
@Parameters {
    inout:&MyDate,
    inout:&MyTime
}

The modes are in (input only), inout (input and can be modified) and out (output only) — see @Parameters.

3. Calling another program

To call an external program, add it to @References/Programs and use Call(...):

@References {
    Programs = ["../programs/POTHER.warp"]
}
@Source {
    Call(POTHER, &MyDate, &MyTime)
}

4. Local procedures and functions

Procedure/Function live inside @Source, with their own variables in @Variables (one entry per procedure/function name, in addition to global):

@Variables {
    global {
        Username char(10)
    }
    Greet {
        name char(10)
    }
}
@Source {
    Function Greet(&name) char(20)
        Return "Hello " + &name
    EndFunc

    &Username = USERID()
    Message("Welcome", Info)  // only valid in Screen; use Print() in Program
}

To call a Procedure (no return value) use Do Name(...); a Function (with a return value) is called as an expression: &variable = Name(...).

5. Next steps

For the full syntax of each section, see the Language reference.