The getfieldproperties( function returns a dictionary containing all of the properties of the specified field. (See the setfieldproperties statement if you want to change one or more field properties.)
This function has two parameters:
database – The name of the database containing the field you want information about. If the field is in the currently active database, this parameter can be
"" or can even be omitted entirely.
fieldname – The name of the field you want information about. The name can be quoted or left unquoted. If you want information about the current field this parameter can be
"" or can even be omitted entirely. You can also specify the field numerically: 1 for the leftmost field, 2 for the second field from the left, etc.
This function returns a dictionary (see initializedictionary(, getdictionaryvalue( and listdictionarykeys() that contains all of the properties of the specified field – it’s name, type of data, width, patterns, etc. Everything you could possibly know about a field is returned by this function.
The getfieldproperties( function may have two, one or zero parameters. Use two parameters to find information about any field in any open database:
If the field is in the currently active database you can leave the database name empty, or even leave the database parameter out entirely. As the final example below shows, the field name does not have to be quoted.
getfieldproperties("","Address") getfieldproperties("Address") getfieldproperties(Address)
In some cases it can be more convenient to refer to the field by number. Fields are numbered starting from 1 on the left. This example returns information about the leftmost field in the database.
A shortcut for getting information about the currently active field is to simply omit all parameters, like this:
The result of this function is a dictionary containing all of the properties of the specified field. You can use the dumpdictionary( function to display the entire contents of this dictionary:
The result will be something like this:
ID=9 NAME="Price" TYPE="Float" DIGITS="Float" ALIGN="Right" WIDTH=5.570000 DEFAULTS="" FORMULA="Quantity*UnitPrice" OUTPUTPATTERN="#,.##" INPUTPATTERN="" CAPITALIZATION="Off" SPACEBARTAB="Off" CLAIRVOYANCE="Off" EDITORMODE="Normal" CHOICES="" RANGE="" DUPLICATES="Yes" LINK="" READLEVEL=0 WRITELEVEL=0 NOTES=""
ID is the field number (fields are numbered from 1 starting from the left).
Use the getdictionaryvalue( function to examine individual field properties.
getdictionaryvalue(getfieldproperties(),"NAME") ☞ Price getdictionaryvalue(getfieldproperties(),"ALIGN") ☞ Right getdictionaryvalue(getfieldproperties(),"FORMULA") ☞ Quantity*UnitPrice
Because the name of the field may be quoted or unquoted in this function (as noted in the parameter description above), a special technique is necessary if you use a variable to store the name of the field whose properties are required. If you used the following code, where the field name is extracted from an array of field names and stored in the local variable, fldName,
fldName = array(FieldNameList,J,cr()) prop = getfieldproperties("Checkbook", fldName)
you would get an error message because Panorama would be looking for a field called fldName and it wouldn’t find one. You need to indicate to Panorama that fldName is not the field name but is a formula that will produce the field name. This is done by replacing the single identifier, fldName, with a string that is obviously a formula. Any formula which produces the required field name will do the job but the simplest solution is to add an empty string to the variable:
fldName = array(FieldNameList,J,cr()) prop = getfieldproperties("Checkbook", ""+fldName)
Panorama then evaluates the formula,
""+fldName and obtains the name of the field.
As a general rule, this technique is necessary whenever you wish to use a variable to store the name of a field passed as a parameter to a statement or function in which the field name parameter may be either quoted or unquoted. These include the datavalue(, fieldalignment(, fieldformula(, fieldnumber(, fieldpattern(, fieldwidth( and grabfieldtype( functions, and the dozen or so lookup( functions whose parameters include a field name.
|10.0||New||New in this version.|