SEU is the AS/400's main source code editor. It is so important that all programmers should get acquainted with it. SEU is a full-screen editor. Although not as powerful as most PC-based editors, it's the most powerful editor IBM has ever made available on any midrange machine.
You can start SEU in two ways: by using the Start SEU (STRSEU) command or by selecting option 2 from PDM. Start SEU to begin editing a new source member in source file MYLIB/QCLSRC. The name of the member will be CLSAMPLE, and the member type is CLP:
STRSEU SRCFILE(MYLIB/SOURCE) SRCMBR(CLSAMPLE) TYPE(CLP)
The system presents the panel shown in Figure 29.9.
Figure 29.9: Working with SEU.
Your panel may look different. It may have fewer open lines between the "Beginning of data" and "End of data" markers. Later, you will see how you can change yours.
Note that you can enter data in two main areas. The left-hand column (filled with apostrophes) is the line command area. In this area, you can enter special commands to insert, delete, and move lines. The data entry area where you enter the actual source code occupies most of the screen, however.
Because member CLSAMPLE is a CL source member, begin by entering a PGM command. In the main entry area, type PGM, as in the example in Figure 29.10.
Figure 29.10: Working with SEU.
Because the source type is CLP, SEU knows that the source code will consist of commands. Commands can be prompted using the F4 key. SEU lets you prompt for the PGM command by pressing the F4 key (with the cursor still on the same line). The result will look like the panel seen in Figure 29.11.
Figure 29.11: Working with SEU prompts.
The example in Figure 29.11 represents the command prompter for the PGM command. Because you are entering source code, the prompter shows two input fields it never showed before: Label and Comment. Enter name in the Label input field, and &option in the first input line that follows. Then press Enter, and you will see a panel like the one presented in Figure 29.12.
Figure 29.12: Working with prompt in SEU.
The command prompter formats the PGM command into your source member. The label automatically goes on column 2, followed by a colon. The command name goes on column 14, and the first parameter's keyword (inserted by SEU for you) begins on column 25.
This activity can continue for many more commands and can become the source code for a complete program in this member. When you are done entering the statements, press F3 to exit SEU. SEU presents the panel in Figure 29.13.
Figure 29.13: Working with SEU.
If you don't change anything and press Enter, SEU updates source member CLSAMPLE in MYLIB/SOURCE. At this point, you have the chance to enter some text description for the source member or to resequence the statements. Then press Enter.
RPG IV is just as easy to code using SEU. SEU has prompt formats for all RPG IV specification types (plus variations). For example, a prompt format is available for the F-spec and another for each variety of F-spec (such as KRENAME).
To edit a new source member called RPGSAMPLE in source file MYLIB/SOURCE, run the following command:
STRSEU SRCFILE(MYLIB/SOURCE) SRCMBR(RPGSAMPLE) TYPE(RPGLE)
The panel in Figure 29.14 appears.
Figure 29.14: Working with RPG IV members using SEU.
To start coding the RPG IV program, enter an F-spec. SEU provides a prompt format for the F-spec. To display, enter the name of the prompt format (F, for the F-spec), and press F4 to see an example like that shown in Figure 29.15.
Figure 29.15: Prompting in SEU.
When you press F4, SEU presents the F-spec prompt at the bottom of the screen, and also shows the lines currently entered (if any) at the top, as seen in Figure 29.16.
Figure 29.16: Prompting in RPG using SEU.
All you need to do now is fill out the input fields and press Enter. SEU will format the F-spec and log it at the top of the screen.
SEU allows you to execute numerous line commands. They will not all be listed here. You can obtain a list by pressing the Help key with the cursor located at the line-command column. The following are the most important line commands:
Delete. Enter a D line command and press Enter; SEU deletes the line that contains the D command. You can enter more than one D and press Enter and SEU will honor all requests at once.
To delete a block of consecutive lines, enter the DD command on the beginning line, another DD command on the ending line and press Enter. You also can enter the letter D followed by a number (such as 10) to delete that number of consecutive lines. The deletions begin at the line where you enter the D command.
Insert. Enter an I line command and press Enter; SEU opens up a blank line for you. You can open up more than one line by entering I followed by a number (such as 15 for fifteen new lines).
Copy. Enter a C line command on the line you want to copy. Then enter an A command on a line if you want the copy to go after that line, or use the B command on a line if you want the copy to go before that line. You also can copy a group of consecutive lines by entering CC on the first line to be copied and by entering CC again on the last line. Then use the A or B commands to place the copy in the right place.
Prompt. Enter a P command on a line to have SEU invoke the correct prompt format for the line as it is written. For example, if the line contains an E-spec (in a source of type RPG), the P command displays the prompt format for the E-specs.
If the line is blank, or if you want to override the prompt you would get by default, you can follow the P with the identification code for the prompt format. For example, you can change a blank line into a C-spec by using the PC command. If you are not sure about the identification code of the format, use a question mark instead. If you run the P? command, SEU will show you a list of available prompt formats.
The I (Insert) and P (Prompt) commands can be combined to insert a new line and invoke the prompter at the same time. For example, you can enter IPF to insert a new F-spec.
Shifting the code. If you are using a free-format language like C or PL/I, you can indent your code. If you insert a test condition into an existing program, you may be turning existing code into a new block that never existed before. Because it is a block, it should be indented. Rather than inserting blank spaces (which might not always work), you can use the R command to shift the code one column to the right, or the L command to shift it one column to the left.
Normally, however, you should shift the code more than one column. In that case, follow the R or L command with a number, such as R3 to shift the code 3 columns to the right. You can also shift a group of consecutive lines using the RR or LL commands (followed optionally by the number of columns, as in RR3 or LL6).
Shifting the Window. SEU always shows a piece of the actual code. There might be code farther to the right that will not fit on the screen. In that case, you can shift the window through which you are looking at the code using the W command. For example, W31 shifts the window so that the first column shown on the left is column 31.
Moving forward or backward. You can always use the Roll keys to page forward or backward. If the distance you have to cover is large, you can use the positioning commands. For example, you can enter a statement number and press Enter. SEU automatically moves the window so that the first line is the statement you requested. Or, you can enter a command such as ‘+150’ to advance 150 statements, or ‘-270’ to go back 270 statements.
SEU has an input-capable line, near the top of the screen labeled "SEU===>", where you can enter special commands. No matter where your cursor is, F10 takes it to the top-line command-entry field. Once you execute a top-line command, F10 takes the cursor back to the place it came from.
Here are some top-line commands:
Quickly move to top or bottom. The T command (or TOP) shifts the window so that it begins with the first statement in the source member. The B command (or BOTTOM) shifts the window so that it ends with the last statement in the source member.
Finding a string. If you want to find a character string in the source member, use the F command. For example, if you enter F EXFMT, SEU searches the source member for the first occurrence of EXFMT.
Changing strings. Use the C command to replace one string with another. For example, to change the first EXFMT into a WRITE, run the C EXFMT WRITE command. If you follow it with ALL, SEU replaces all occurrences of EXFMT with WRITE.
Uppercase/lowercase. Use the SET CAPS ON command to force SEU to accept only capital letters. Use SET CAPS OFF to allow both uppercase and lowercase input.
SEU has more commands. If you need more information, place the cursor in the SEU===> prompt and press the Help key. For more detailed help about a particular command, type the command name (for example, C for the change command) and press the Help key.
Besides the obvious function keys (F3=Exit, F4=Prompt, F5=Refresh, and F12=Cancel), SEU supports three that present other panels.
F13 lets you customize your SEU session. For example, you can control how much SEU advances or goes back when you press the Roll keys. Choose the Cursor setting (C). With the C setting, the Roll keys roll only enough to move the line (where the cursor is placed) on the top line or bottom line, depending on the direction of the roll. The C setting gives you complete control over the Roll keys. Figure 29.17 reflects the screen that F13 presents.
Figure 29.17: Changing Session Defaults in SEU.
Although the F and C top-line commands let you perform some finding and changing, they don't allow as many options as F14 does. Figure 29.18 shows the screen presented by F14.
Figure 29.18: Find/Change Options in SEU.
The F15 key lets you display and/or copy either another source member, a spool file, or an output queue. While you perform this function, the SEU display splits in two halves: upper (current edit session) and lower (the other item). Figure 29.19 shows what F15 presents.
Figure 29.19: Browse/Copy Options using SEU.
F16 repeats the last Find operation, F17 repeats the last Change operation, and F21 opens up a window from which you can enter and execute any system commands.