The fieldnumber( function returns the number of a database field (starting with 1).
This function has two parameters:
database – database containing the field, or
"" for the current database.
field – the field name.
This function returns the number of a database field (starting with 1).
fieldnumber("Mailing List","Name") ☞ 1 fieldnumber("Mailing List","Address") ☞ 2 fieldnumber("Mailing List","City") ☞ 3 fieldnumber("Mailing List","State") ☞ 4 fieldnumber("Mailing List","Zip") ☞ 5
If the requested field does not exist, the function returns zero.
fieldnumber("Mailing List","Email") ☞ 0
You can use a formula to specify the field name, but if the formula is a variable or another field, you will need to modify the formula so that it contains an operator or function, not just a field name.
Local x x="City" message fieldnumber("",x) ☞ 0 message fieldnumber("",""+x) ☞ 3
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()) num = fieldnumber("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()) num = fieldnumber("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(, fieldpattern(, fieldwidth(, getfieldproperties( and grabfieldtype( functions, and the dozen or so lookup( functions whose parameters include a field name.
|10.0||No Change||Carried over from Panorama 6.0.|