*** This documentation is a work in progress ***

Methods

9.1 Example:

class myapp:myclass {  // comment can go here
    display(long my, long mx){  // comment can go here
// comments can be put on multiple lines
// like this
        for i=1 to 10    // comments can be put on the end of code lines
            ? i
        next
//
// comments can be put on a line by themselves
//
        return i
    }   // and this comment is on the last code line
}

or

#app myapp
#class myclass
#method display
#parm long my
#parm long mx

for i=1 to 10
    ? i
next
return i
Note: The 2 examples above are compiled exactly the same. The second method is used by the IDE(Interactive Development Environment) to edit and compile just a single method of a class.

9.2 Method Variables:

Note: Assigning a value to an object property will NOT change it's type or size. (Blobs are references so they can change in size) However, all method variable types and sizes are set to whatever value is assigned to them using the "=" sign in an assignment statement. A method variable can change it's type during the course of a method but the consequenses of this are left up to the programmer.
Examples:

// the following would create a variable but give it no value : a.is_null() is _TRUE
	logical a
	int a
	long a
	double a
	number a
	date a
	char a
	blob a
// the following would create the variable and create a new object or data string : .null is _FALSE
	long a[5]                 // space allocated and all elements are set to zero
	char a(20)                // creates space for string and fills with \0 (binary zeros)
	blob a(100)               // creates blob of length 100 but size can be changed with "resize" method
	object a(myclass)         // creates a new object based on myclass : all properties are set to zero
	index a(myclass)          // creates a new index based on myclass : no entries
	table a(myclass, 100)     // creates a table based on myclass : record count is 0
// note: all vectors and matrixes are set to 0 at definition time : is_null() is _FALSE
// All vector and matrix variables are given the type "V" and have the properties of width and length.
// The value returned from them, however, is of the type of the vector or matrix variable, not type "V". (see 9.5 Vector and Matrixes)
All Methods Variables Contain These Properties: The following information can be had from the default info() method of any Method Variable.
  
  • NAME=A
  • // name of the variable in the method : this isn't the full name of an object necessarily
  • TYPE=LONG
  • // this is the variables type
  • SIZE=4
  • // this is the amount of space taken in the method : some variables use space elsewhere are so only a reference is stored
  • NULL=YES
  • // this is YES if no data has been put in the variable : NO otherwise : useful for checking if a parameter passed any data
  • TEMP=NO
  • // this is YES only if it is used for storing temporary results or constants
  • CLASS=TOOLS:LONG
  • // all variables have a Class
    Note: HAL contains the methods format(), info(), set(), and is_null() for all variables. These are used to display the data (format), get information on the variable(info), get and set the value of the varaible (set) and return whether the variable has a value (is_null).

    9.3 Constants:

    Note: In the string example a "\'" was used to put a "'" in the string even though that character was being used to define the string. See the appendix for a complete list of character escape sequences.
    Note: There are no constants for the int, number, class, object, blob, index or table variables.

    9.4 Compiler Directives:
    Each of the following statements tell the compiler information that is used in compiling a method.

    #include [file name]
    #define [variable]=[object or class hierarchy]
    #app [app name]
    #class [class hierarchy]
    #object [object hierarchy]
    #method [method name]
    #parm [parm definition] 

    9.5 Vectors and Matrixes:
    Examples:

        long a[5]                 // all 5 elements are set to 0
        int b[10000]              // all 10000 elements are set to 0
        long c[2,3]               // all 6 elements are set to 0
        char d(20)[100]           // vector is created and all strings are set to \0 (binary zero)
        object mine(myclass)[20]  // vector is created but no object is made
    
    Examples:
    a[2]=19000   // store 19,000 into 2 element of a
    b[250]=a[2]  // store 19,000 into 250th element of b after converting from 4 to a 2 byte integer
    j=c[2]       // create vector of length 3 called j and store row 2 of c in it
    k=a          // create vector k of length 5 and store all 5 elements of a in it
    m=mine[10]   // create object variable called m and put 10th element of mine into it (stores reference but doesn't create a new object)
    
    Note: Look at the block structure for quickly traversing a vector or matrix.
    long a[2,5]
    block a
        ? a      // this would print a row wise listing of matrix a
    endb
    
    long a[2,3],b[2,3],c[2,3]
    block a,b,c  // this block will loop for all the elements in the first variable
    	c=a+b    // this would put the sum of each corresponding element of a and b into c
    endb
    
    long a[2,3]
    b=0
    block a
        b=b+a    // this puts the sum of all elements of a in b
    endb
    

    9.6 Tables:

    Note: There is an exception to the above definition of vectors and matrixes. (A "TABLE" variable CANNOT be defined as a vector or matrix.)

    Example:
    class myclass {
        char name(30)
        char add_1(30)
        char add_2(30)
        char city(30)
        char state(2)
        char zip(10)
    }  // record length is 132 bytes
    //
    object a(table)[10]      // this creates a vector of tables of length 10
    =a[1].new(myclass, 100)  // this would create the table based on myclass with cluster size 100
                             // and store the reference to it in the first element of a
    #class xyz
    #method display
    //
    table cust(myclass, 100)  // this line creates a new table called cust using class myclass allocating 100 rows at a time
    //
    cust.name="David Clark"   // one object of myclass is allocated for a table
    =cust.append()
    ? cust[1,1]      // displays "David Clark" Note: Records start at 1 not 0.
    ? cust[1].name   // so would this
    ? cust[1]        // display all data in the first row of cust
    ? cust.count()   // would show 1 record in cust
    //
    // Note: By accessing a row or a field of a row, the data from that row is stored in the default object.
    //
    cust.name="Name 2"
    =cust.append()
    ? cust.name     // would show "Name 2"
    ? cust[2]       // would display all data from row 2 including "Name 2"
    ? cust[1].name  // would show "David Clark"
    ? cust.name     // and so would this
    =cust.append("David Clark,71 Whitehead Cres,,Brandon,ND,12345")  // this would add this data to all the fields of record 3 in cust
    // or
    cust="David Clark,71 Whitehead Cres,,Brandon,ND,12345"   // this would fill in the default object
    =cust.append()   // this would add record 3 to cust from the default data