# FIELDLEN()

Syntax:

Then: xx=FIELDLEN(lookupname,fieldno)

"lookupname" is the name of the lookup file. Use a dash "-" to represent the current file.
"fieldno" is an expression designating the field number for which you want the length.

Return value is a numeric field containing the length of the target field.

Version Ref: 4.5

Description:

Returns the length of the specified field in a lookup file.

Examples:

Retrieves the length of a lookup field and places it in variable aa.

Then: lookup inv=arinvoice k=2 i=a nx
Then: aa=fieldlen(inv,"5")

Assigns a length to a field based on the length of a lookup field.

Then: lookup inv=arinvoice k=2 i=a nx
Then: aa(10,fieldlen(inv,"5"))

The following code uses other filePro field functions to display the "map" of a lookup file. It displays the field names, lengths, and edit types in a listbox that looks similar to an actual map printout. (Assumes the lookup name is "file".)

Then: dim map(100)(60,*)
Then: no(3,.0) = "1"
If: numfield(file) eq "0"
Then: errorbox "No fields" ; end
loop If: no gt numfield(file) or no gt "99"
Then: goto done
Then: map[no] = no & " - " &
doedit(fieldname(file,no),"*","45") & " " &
doedit(fieldlen(file,no),".0","3") <
fieldedit(file,no)
Then: no = no + "1" ; goto loop
done If:
Then: aa = listbox(map,"1",no-"1")

Note the use of the DOEDIT() function while building the map entry. This guarantees that all entries will be of the same length, and the columns will be aligned.