Download GURGLE - GNU Report Generator Language
Transcript
22 The %$ operator gets the type of the field This is a one character string which will be C (character/string), N (numeric), D (date), L (logical), or M (memo) although this last type is not supported as a data type. The given field name can be more complex than a simple name to support referencing more that one database file and direct record indexing within that database file. The syntax of this is given below using the get field operator % as an example although any of the field operators above accept the same syntax variants. The %field syntax just gets the value of the field from the current record and is the default syntax given above. The %field[index] syntax gets the value of the field from the record with the given index (record indecies go from one to the number of records in the database). The %database->field syntax gets the value of the field from the current record of the given database (name should match that given when the database file was declared using the database predefined macro without the pathname or extension). The %database->field[index] syntax gets the value of the field from the record with the given index of the given database. The index can be a simple numeric literal or any normal expression that returns a numeric value (which must be greater than or equal to 1 and less than or equal to the total number of records in the database). There should be no whitespace in the above syntax forms except where the index is a more complex expression which can include whitespace if neccessary. The above syntax forms all bypass any active filters. The current record forms when referring to a database other than the master database will always refer to the first record of that database. Here are some examples of field referencing from an equate. %NAME >> s1 %CATS->NAME + %CATS->TYPE >> s2 1 >> a %DOGS->NAME[2+a] >> s3 The first example gets the contents of the NAME field from the current record of the current database (the current database is always the master database unless operating under a roll ... through loop through another database). The second example gets the contents of the NAME and TYPE fields of the current record in the cats database, adds them together and assigns the result to the s2 variable (the two fields must have the same data type). The last example gets the contents of the NAME field of the 3rd record in the dogs database and assigns the value to the s3 variable. 0.4.9 Constructs There are two looping constructs and a conditional construct. The basic looping construct has the form while ... do ... endwhile. While the expression to the left of the do keyword is true do the expression to the right of the do keyword. The expression on the left must produce a boolean value. The left and right expressions can include any complex expression, such as nested looping and conditional constructs or function calls. An example of this looping construct is given below with the definition of strlen (to return the length of a string).