FILE [ HP RPG/XL Utilities-Part 2 RISE ] MPE/iX 5.0 Documentation
HP RPG/XL Utilities-Part 2 RISE
FILE
FILE allows you to edit a file directly.
Form
FIL[E] filename [N[OW]]
Parameter Explanation
filename Name of the file to be edited directly.
N[OW] Execute the command immediately without safety prompts.
NOW is significant with FILE if, previous to issuing the
command, you were editing a copy of another file. If
you were directly editing another file, having used the
FILE command, that file will be closed automatically,
and your changes made permanent. However, if you used
the TEXT command to copy it into a work file, RISE will
not open another file unless you enter the KEEP command
to save your changes, or specify the NOW parameter to
discard your changes. The NOW parameter is used when
immediate execution is required. It disables safety
prompts.
If you choose not to use the "NOW" parameter, RISE will
return a safety prompt asking if you want to clear the
current work file. If you respond with "Y[ES]", it will
clear the file, and another file will be accessed for
editing. If you respond with "N[O]", it will cancel the
FILE command so that you may perform a KEEP first if you
wish.
Purpose
The FILE command allows you to edit directly a file named "filename". If
"filename" is not already a KSAM file, RISE will create one for editing
and prompt you for maximum number of records in the new file. In other
words, the KSAM work file is your permanent source file.
FILE is especially useful when your source program is long. If you use
the TEXT/KEEP commands to bring the file to the terminal for editing or
additions, this means that a permanent file must be copied into a work
file (KSAM file). Such copying increases overhead. The FILE command
does not require a file to be copied.
A disadvantage of the FILE command is that an error that occurs during
editing cannot be corrected easily and quickly unless a backup copy was
made for purposes of restoration before the editing began.
The FILE command specifies that the file "filename" is the file which is
to be edited directly. RISE then ensures that "filename" is in the KSAM
file form. To do so, three possible cases must be considered.
Case 1. Creating New File
The file "filename" does not exist and must be created as a KSAM file.
In order to do this, you create the file.
You type > FILE "filename" **
RISE responds Creating new KSAM file, enter maximum number of records.
Case 2. Accessing Old KSAM File
"filename" has been created as a KSAM file (called "newfile" below).
You type > FILE "newfile"
RISE responds File opened.
** You do not enclose the filename in quotes when entering a command.
Quotes are used around filename in these cases to indicate a place holder
representation of the real name of your file. For example, FILE
"filename" could represent FILE SIMCAL.
Case 3. Converting Non-KSAM File to New KSAM File
"filename" exists but is not a KSAM file. RISE must convert it. (The
converted file is called "newfile" below.)
You type > FILE "filename"
RISE responds Enter new file name followed by additional number of
records.
You type "newfile" 100
(If you are adding records to those in "filename" (now called "newfile")
enter the number of additional records you will add--100 in this example.
The default is the number of records in "filename".)
To access converted files in the future, type FILE "newfile".
Related Commands
The TEXT and KEEP commands achieve results similar to those of FILE and
EXIT TEXT and KEEP have the disadvantage of additional overhead while
files are being copied to a work file and recopied to a permanent file.
The advantage is that any erroneous editing of the work file pertains
only to the work file. The permanent file remains in its previous state.
See TEXT and KEEP for further information concerning these commands.
It is recommended that TEXT and KEEP be used with small files since their
copy time will be minimal. FILE and EXIT are best suited to large files
in their developmental stage. When the source program is fully developed
and in production, use TEXT and KEEP to avoid key file overhead in
storing.
A KSAM file actually consists of two files: the data file and the key
file. If you want to purge both parts of a KSAM file, use the following
commands:
:RUN KSAMUTIL.PUB.SYS
>PURGE "filename"
>EXIT
For further information concerning KSAM files, please see the KSAM
REFERENCE MANUAL, part number 30000-90079.
Leaving FILE
Use the EXIT command to leave FILE. It will terminate RISE and return you
to MPE with your changes made permanent. You can also use the BEGIN
command to leave FILE. It will close the file you are directly editing
and allow you to begin a new editing session as if you had just entered
the RPG Interactive System Environment.
* Execution mode: Line or Block.
* Record Pointer: At first line in file.
Examples
The following are legal abbreviations which may be used with the FILE
command and its parameters:
FILE FILE1 N Ready a work file named FILE1 for immediate editing.
FIL FILE1 Ready a work file named FILE1 for editing.
In the first example, the FILE command is used to create a new KSAM file
named SIMCAL2. A message is returned asking for the maximum number of
records to be included in the new file. The number given is 5 (1). This
is an example of Case 1 (see above).
The ADD command is entered, and an attempt to add the 6th record is
nullified. The error message gives the reason and recommends using the
XPAND command to increase file size (2). When XPAND is entered without
the number of records to expand the file by, another error message
appears (3).
The XPAND command is again tried, this time with the maximum number of
records specified alphabetically rather than numerically. This generates
another error message (4).
When the XPAND command is properly entered, an execution message is
displayed (5). The ADD that follows is accepted by RISE, and lines are
added before <Control Y> is applied to exit Add mode (6).
>FILE SIMCAL2
(1) Creating new Ksam file, enter maximum number of records.
5
File opened.
>ADD
1 :LINE 1
2 :LINE 2
3 :LINE 3
4 :LINE 4
5 :LINE 5
6 :LINE 6
(2) Error 147: No room in edit file, use XPAND.
(3) >XPAND
Error 137: Missing number of records to expand by.
(4) >XPAND FIFTY
^
Error 138: Illegal numeric value.
(5) >XPAND 50
Xpand completed.
>ADD
5 :LINE 5
6 :LINE 6
7 :LINE 7
8 :<Control Y>
(6) >EXIT
In the second example, which typifies Case 3 (above), SIMCAL exists but
is not a KSAM file, and RISE must convert it. A message in response to
the FILE command asks for a new file name and a maximum number of records
(1). When the filename and record number are given, the file is opened
(2). The converted file is then listed (3).
The third example of the FILE command usage represents Case 2, in which
an old KSAM file (SIMCAL2, which was created in the first example) is
made available for direct editing using the FILE command. RISE responds
with a message stating that the file is opened (1). LIST ALL shows the
contents of the file (2). Exit is used to leave RISE (3).
>FILE SIMCAL2
(1) File opened.
(2) >L A
1 LINE 1
2 LINE 2
3 LINE 3
4 LINE 4
5 LINE 5
6 LINE 6
7 LINE 7
(3) >EXIT
END OF PROGRAM
:
In the fourth example, the TEXT command is used with SIMCAL, and the
first five lines are listed (1). Next, the five lines are deleted (2).
When the user attempts to change work files to SIMCAL3, using the FILE
command, a safety prompt is displayed. The negative response results in
a cancellation of the FILE command (3).
SIMCAL, with the first five lines deleted, is then copied into a
permanent file named SAVEFILE using the KEEP command (4). Two execution
messages are displayed (5). A DELETE ALL command is given. Note that
line 6 is the first in the file (6). <Control Y> is applied to halt the
listing of the deleted lines but, as the message indicates, it does not
halt the deletion (7). The FILE SIMCAL3 command, this time with the NOW
parameter added to disable the safety prompts, is executed (8).
>TEXT SIMCAL
Text completed.
>
(1) >L 1/5
1 00011H
SIMCAL
2 00012FINPUT IP F 72 DISK
3 00013FOUTPUT O F 72 DISK
4 00014IINPUT AA 01 1 CA
5 00015I OR 02 1 CS
(2) >D 1/5
1 00011H
SIMCAL
2 00012FINPUT IP F 72 DISK
3 00013FOUTPUT O F 72 DISK
4 00014IINPUT AA 01 1 CA
5 00015I OR 02 1 CS
Delete completed.
>
>FILE SIMCAL3
(3) KEEP not done, CLEAR current work file?NO
File cancelled.
(4) >KEEP SAVEFILE
(5) Keep completed.
File name is SAVEFILE
(6) >D ALL
6 00016I OR 03 1 CM
7 00017I OR 04 1 CD
8 00018I OR 05
9 00019I 8 72OPRND1
10 00020I 9 132OPRND2 99
11 00021C 01 OPRND1 ADD OPRND2 RESULT 104
12 00022C 02 OPRND1 SUB OPRND2 RESULT
13 00023C 03 OPRND1 MULT OPRND2 RESULT
14 00024C 04N99 OPRND1 DIV OPRND2 RESULT H
15 00025C 04 99 <Control Y>
(7) Delete completed.
(8) >FILE SIMCAL3 NOW
Fi1e opened.
>EXIT
END OF PROGRAM
The last example shows how to purge files created by the FILE command as
well as the key files associated with KSAM files. First KSAMUTIL.PUB.SYS
is run, and an HP banner is displayed (1). The user then enters the file
names of the files with the PURGE command (2). Note that the execution
messages contain those filenames plus the RISE-created file designators
of the associated key files in the execution messages (3).
The EXIT ends the KSAM UTIL program (4).
(1) :RUN KSAMUTIL.PUB.SYS
HP32208A.03.03 WED, MAY 27, 1981, 3:55 PM KSAMUTIL VERSION:A.03.03
HP32208A.03.03 WED, MAY 27, 1981, 3:55 PM KSAMUTIL VERSION:A.03.03
(2) >PURGE SIMCAL2
(3) SIMCAL2.RPG.SUBSYS & SIMCA97 PURGED.
>PURGE SIMCAL3
SIMCAL3.RPG.SUBSYS & SIMCA18 PURGED.
(4) >EXIT
END OF PROGRAM
:
MPE/iX 5.0 Documentation