FIELDNAME()

 

Syntax:

      Then: xx=FIELDNAME(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 name.

 

Return value is a text field containing the name of the target field.

 

Version Ref: 4.5

Description:

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

 

Examples:

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

      Then: lookup inv=arinvoice k=2 i=a -nx
      Then: aa=fieldname(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.

 

Version 5.6

FIELDNUM() was added to return the field number of the FIELDNAME of a lookup