Field Names in Processing Trick

Bruce Easton bruce at stn.com
Tue Nov 14 13:04:44 PST 2006


Bob Simcoe showed a neat trick for prompting user for field name to enter
using the map:

>>  Number   -------------Field Heading--------------    Len   --Type-
>>     1 -   MasterCustNo                            ?     6?  rjfill0
>>     2 -   IntCustNo                               ?     6?  rjfill0
>>     3 -   CreateDate                              ?    10?  mdyy/
>>     4 -   Customer Number                         ?    10?  allup
>>     5 -   Customer Name                           ?    35?  allup
>>     6 -   Address Line 1                          ?    35?  allup
>>     7 -   Address Line 2                          ?    35?  allup
>>     8 -   Address Line 3                          ?    35?  allup
>>     9 -   City                                    ?    20?  allup
>>    10 -   State                                   ?     2?  stprov
>>    11 -   Zip Code                                ?    10?  zipna
>>    12 -   County                                  ?    25?  allup
>>    13 -   WebSite Address                         ?    70?  *
>>    14 -   A/P Contact                             ?    35?  uplow
>>    15 -   A/P Phone                               ?    14?  phone
>>
> then Nancy Palmquist wrote on Tue 11/14/2006, 9:20 AM:
>
> I recently rediscovered the fieldname(), fieldval() functions and hoped
> against all hope that the first option could be an expression but alais
> it can not.
>
> fieldval(lookupname,fieldnum), lookupname can not be an expression,
> fieldnum can be an expression.
>
> Nancy
>
There must be some good reason why these functions were implemented in a way
that requires a lookup/current-file-reference rather than being able to just
get the map info without doing a lookup, but if a function was able to just
read the map without any join, then, in that case, I would think the first
argument could be variable or just a variable expression for a filename.

I recently did some input processing where I wanted to code the prompts
similarly, and in this specific case, I had a need to take control of all
the prompts at the bottom as well.  Here is an alternate way using the same
map (see top):

   1   -------   -   -   -   -   -   -   -   -   -   -   -
 top         If:
           Then:   'esc esc stuff
   2   -------   -   -   -   -   -   -   -   -   -   -   -
             If:
           Then: end
.
.
.
   14  -------   -   -   -   -   -   -   -   -   -   -   -
 @update     If:    'these 2 arrays must match # flds in file
           Then: dim overrnm(30)(40,*); dim brwsnm(30)(40,*)
   15  -------   -   -   -   -   -   -   -   -   -   -   -
             If:    'assign only to OVERRIDE MAP NAMES
           Then: overrnm["1"]="Master Number"
   16  -------   -   -   -   -   -   -   -   -   -   -   -
             If:
           Then: overrnm["3"]="Date Created"
   17  -------   -   -   -   -   -   -   -   -   -   -   -
             If:    'assign only for BROWSE LOOKUP FIELDS
           Then: brwsnm["12"]=", \kB to Browse Counties"
   18  -------   -   -   -   -   -   -   -   -   -   -   -
             If:
           Then: screen; goto top
   19  -------   -   -   -   -   -   -   -   -   -   -   -
 @wef*       If:
           Then: cls("22") 'may want this below tst on ln 21
   20  -------   -   -   -   -   -   -   -   -   -   -   -
             If: 'check to see that field is real num. fld.
           Then: declare FldNumber(3,.0); FldNumber = @fd
   21  -------   -   -   -   -   -   -   -   -   -   -   -
             If: FldNumber lt "1"
           Then: end   'or jump to a dummy @wef handler
   22  -------   -   -   -   -   -   -   -   -   -   -   -
             If:
           Then: declare FldName(40,*)
   23  -------   -   -   -   -   -   -   -   -   -   -   -
             If:
           Then: FldName = fieldname( - , FldNumber )
   24  -------   -   -   -   -   -   -   -   -   -   -   -
             If: overrnm[@fd] ne ""
           Then: showctr("21") "Enter"<overrnm[@fd]{brwsnm[@fd]
   25  -------   -   -   -   -   -   -   -   -   -   -   -
             If: overrnm[@fd] eq ""
           Then: showctr("21") "Enter"<FldName{brwsnm[@fd]
   26  -------   -   -   -   -   -   -   -   -   -   -   -
             If:
           Then: gosub rcrdmsg; end
   27  -------   -   -   -   -   -   -   -   -   -   -   -
 rcrdmsg     If:   '** could be called by any type of @wef
           Then: showctr("24") "\k4-Record  \kY-Cancel"
   28  -------   -   -   -   -   -   -   -   -   -   -   -
             If:
           Then: return

This should result in  the bottom prompt to say:

                       Enter Date Created

                   ESC ESC -Record  DEL -Cancel

for field 3, but:

                Enter County,  F6 to Browse Counties

                   ESC ESC -Record  DEL -Cancel

for field 12 (depending on your platf/termcap).

Bruce

Bruce Easton
STN, Inc.





More information about the Filepro-list mailing list