Home | The Company | Publications | Products | Links | Tips |
---|
When you are trying to pass the occurence number of the element from the map to the helproutine you can use an example program from the NATURAL Developers Handbook of WH&O. Below is the example:
> > + Program TSTHELP3 Lib All ....+....1....+....2....+....3....+....4....+....5....+....Mode 0010 DEFINE DATA LOCAL 0020 1 #OPT(A10/10) INIT 0030 <'001','002','003','004','005','006','007','008','009','010'> 0040 1 #IDX(I2) 0050 END-DEFINE 0060 INPUT (IP=OFF AD=MI'.' HE='HELP3',#IDX) 0070 2/5 'OPTIONS:' 0080 3/5 #OPT(1) 0090 4/5 #OPT(2) 0100 5/5 #OPT(3) 0110 6/5 #OPT(4) 0120 7/5 #OPT(5) 0130 8/5 #OPT(6) 0140 9/5 #OPT(7) 0150 10/5 #OPT(8) 0160 11/5 #OPT(9) 0170 12/5 #OPT(10) 0180 END > > + Helproutine HELP3 All ....+....1....+....2....+....3....+....4....+....5....+.... 0010 DEFINE DATA PARAMETER 0020 1 #PASSED-FIELD(A10) 0030 1 #OCC(I2) 0040 END-DEFINE 0050 DEFINE WINDOW BTEAM 0060 SIZE 5*30 0070 BASE 20/1 0080 TITLE '- ARRAY HELP -' 0090 FRAMED ON 0100 INPUT WINDOW='BTEAM' #PASSED-FIELD (AD=MI'.') 0110 / '>' #OCC (AD=OI) 0120 END
With the variable #IDX included in the HE= parm, you will get:
NAT0936 Format/length conflict in parameter 1.
If #IDX is omitted from the HE= parm, you will get:
NAT0935 Conflict in number of parameters.
How can you get the index passed to the Helproutine, the programmer wants to use the index to access the corresponding occurrence of another array on the map?
The help routine is defining the #OPT parameter as a scalar field and it should be an array. When you put a help routine on an array field, NATURAL passes the array to the help routine. Then you use the #IDX field to determine which occurrence of the array needs the help.
NATURAL can support your request quite easily, although not very well documented. The list of parameters that passes from the map to the Helproutine include two sets of parameters.
The first one is the list of parameters that were specified directly in the HE= list of parameters, right after the Helproutine name. This list may include up to 20 parameters. Although you can have a number of additional parms, depending on how large your parm field names are, they may not fit in the 2 additional lines you get to define them in.
The automatic parameters that are added at the end, after the first list. This may include up to 4 additional parameters, depending the option usage by the programmer.
The first one in the value of the original field that we asking Help for it. The format should be the same as the original field format.
The second one may be the field name in a A65 format field. This can be achieved by adding "=" in the list parameters of the HE parameter.
The index of the chosen field in the array if the original field is an array. The index should be defined as I2 format parameter.
The above explanation may indicate that there is no need to define an Index field in the calling program, maintain its value according to the current position in the array and pass it as a separate parameter to the Help routine. This service is offered automatically by NATURAL, but not all are aware to this option....
For more information please see NATURAL Programming Guide, Version 2.2, page 179, manual order number NAT228-021ALL.