MainframeSupports
tip week 46/2003:

With the introduction of the internet hypertext became a part of every day life. We click on a marked up text and suddenly we are looking at anothor page on the internet. The concept is simple and brilliant and it has been possible to use in the ISPF editor before anyone thought of the internet, even Al Gore.

At your installation you may use a feature, where you write a command name in the command line, then you place the cursor at a dataset name and hits Enter. Next thing you are browsing or viewing or even editing the dataset or member with that name. This is in fact what hypertext is all about. This tip will show you how to create your own hypertext command.

The most important tool is of course an EDIT macro. Here is an example in REXX:

/* REXX: HYPERTXT */
ADDRESS ISREDIT
"MACRO"
"(LRECL) = LRECL"
"(LINENO, POSNO) = CURSOR"
IF POSNO > 0 & POSNO <= LRECL
THEN DO
  "(MYLINE) = LINE "LINENO
  IF POS(SUBSTR(MYLINE, POSNO, 1), '0123456789') > 0
  THEN
    ADDRESS ISPEXEC "VIEW DATASET(MY.NUMBER.DATASET)"
  ELSE
    ADDRESS ISPEXEC "EDIT DATASET(MY.LETTER.DATASET)"
END
ELSE
  SAY 'CURSOR NOT IN DATA'
EXIT

The most important things are happening in line 4, 5 and 6. These lines determines the position of the cursor: is it in the data part of whatever you are viewing or editing. If the cursor is not in the data part, the REXX will tell you about it. If the cursor is indeed in the data part the good stuff begins. In line 8 the REXX picks up the contens of the line that the cursor is positioned on and puts it into the REXX variable MYLINE. From here on only your imagination sets the limits. POSNO holds the actual position of the cursor within the line. Just to illustrate my point I have chosen to VIEW dataset MY.NUMBER.DATASET if the cursor is positioned on a digit, otherwise I EDIT a dataset called MY.LETTER.DATASET. The hard part is to create some code that is able to identify a datasetname, so you can use this instead of some hard coded value as in this example.

The clumsy thing about the above REXX is the way that it is activated. First you have to write HYPERTXT in the commandline without pressing Enter. Second you have to position the cursor somewhere in the data part and third you must press Enter. You will be bored with this routine after a while (or maybe you already are). Fortunately there is a clever solution to this problem. Use the KEYS command and assign the value HYPERTXT (or whatever name your hypertext command has) to one of the PF-keys and exit KEYS again. Now you can just position the cursor in the data part where ever you like and press the PF-key assigned to your hypertext command. The miracle happens right away. I use PF6 for my hypertext REXX. Normally PF6 is assigned to ISPF EDIT/VIEW command RCHANGE, which I almost never use. Other good opportunities are PF4 which is often assigned to the RETURN command. Normally you will avoid using RETURN, so you can replace it with your own command instead.

Previous tip in english        Sidste danske tip        Tip list