Does anyone have a way of getting the data entered in one field on a map to a Helproutine on another field, so it can take different action based on the other field.
So I have 2 fields on a map #a and #b. Field help is available on #b but I also want the contents of #a to be passed to the helproutine.
I know how to pass the additional parameter to the Helproutine, but the data from that field isn’t available until I press Enter and then press PF1 for help. The documentation also points out that help takes precedence over passing data from the screen to the map variable.
So is there any way around this.
There are two ways I know to do this. Here is a program and a Helproutine:
DEFINE DATA LOCAL
1 #LAST (A20) INIT <‘’>
1 #FIRST (A20) INIT <'’>
SET KEY PF1=HELP NAMED ‘HELP’
INPUT (AD=M) 3/10 ‘LAST NAME HERE==>’ #LAST
6/10 ‘FIRST NAME HERE==>’ #FIRST (HE=‘HELP02’,#LAST)
IF #FIRST = ‘***’
REINPUT USING HELP MARK FIELD *#FIRST
DEFINE DATA PARAMETER
1 #LAST (A20)
1 #FIRST (A20)
IF #LAST = ‘’
MOVE '’ TO #FIRST
SET CONTROL ‘Q’
WRITE ‘LAST NAME IS’ #LAST
Basically, we go to the Helproutine twice. The first time the Helproutine tests #last, which is functioning like a “flag”. We now set a “return flag”, #first, which says, I am not in a position to help you. If you want to see what is going on, change the ‘Q’ to ‘N’. You will see the return to the program (as long as you look quickly). When we get back to the Helproutine, the ‘Q’ drops us through to the IF on #FIRST. This takes us back to the Helproutine, but now, the screen has been “read”.
The code above is just to demo the process. The asterisks are for visual reinforcement of what is going on.
The other approach does not work on the PC, just the mainframe. There is a whole family of %C commands which allow you to “read the screen”. Thus, in a Helproutine I could issue the command (using SET CONTROL) %CCL05A. This would read the entire fifth line of the screen into the system variable *COM. I could then “parse” this string to get the last name (for example, on the screen I might have "enter name here==>’ I would then EXAMINE the string looking for the >, then add two to get to the name field.
I believe I have an article on this in an old Inside Natural issue. If you still need some help, send me an e-mail with your mailing address and e-mail address, and I will try to find the edition with the article to send to you.
One more note. As I said, the code above was just to demo the principle. After the WRITE at the end of the Helproutine, add MOVE ‘STEVE’ TO #FIRST, otherwise you will be in a loop.
Hey, thanks Steve. I learned two things today - set control C and Q.
For XT, the important thing to note is that you can pass other map fields to a help routine by stringing onto the HE parm. When you do this, the field that the help routine is associated with will be passed last by default. This is why in HELP02, the parameters are defined as #LAST #FIRST.
See the natural manual for more details on HE= http://techcommunity.softwareag.com/ecosystem/documentation/natural/