• No se han encontrado resultados

3.1. Variables a utilizar

3.1.2. Incorporación de Tecnología:

An important part of CL command syntax is the use of a parameter keyword, a signifi cant word that names a command parameter. CL commands use keyword notation to explicitly identify a command’s parameters. When you use parameter keywords, the parameter value must immediately follow the keyword, and the value must be enclosed in parentheses, as the following syntax statement illustrates:

Each keyword-value set is a single parameter. One or more spaces must separate the com- mand name from the fi rst parameter and separate each parameter from the next parameter. When you use keyword notation, the order of parameters is not essential. Consider again the

CRTLIB command. When you type CRTLIB on a command line and prompt for the command

(by pressing F4), the CRTLIB command prompt screen (Figure 2.1) appears.

From this screen, you can see that the normal order of parameters is Library, Library type, and Text. Yet if you use keyword notation, either of the following commands, or any of the several other possible permutations, entered on a command line or in a CL program, would work:

CRTLIB LIB(PAYROLL) TYPE(*TEST) TEXT('Payroll Development') CRTLIB TYPE(*TEST) TEXT('Payroll Development') LIB(PAYROLL)

Both commands work because the system properly interprets a specifi ed parameter value as belonging to the named keyword that immediately precedes the value.

You can determine the parameter keywords for any CL command by observing the command’s prompt screen in an alternate, or keyword, format. For example, to get to the

CRTLIB command prompt keyword display from the initial command prompt screen you see

in Figure 2.1, you might fi rst want to press the F24 function key to view additional function keys. After you press F24, the screen in Figure 2.2 appears.

The function-key list at the bottom of the screen now includes F11=Keywords. Recall how we used F11 to change the screen format of the Display Installed Licensed Programs display in Chapter 1, Lab 1. In the command prompt context, F11 acts as a toggle between the initial (Choices) command prompt screen (Figures 2.1 and 2.2) and the prompt screen’s keyword format you see in Figure 2.3.

Figure 2.3: Create Library (CRTLIB) Command Prompt Screen in Keyword Format

Tip

All screens have a certain number of active function keys, depending on the type of screen. When many function keys are active and they cannot all be displayed on the two lines allowed, F24=More keys is displayed. But if you know that a function key is active for a certain screen, you can use the key even if it does not appear in the two-line function-key list. For example, F11

works from any command prompt screen; knowing this, you don’t have to press F24 fi rst just to see that F11 is active.

By looking at Figure 2.3, you can see that the keywords (LIB, TYPE, and TEXT) we used earlier for the CRTLIB command were correct. If you enter values for the parameters, the command prompt screen looks like the one in Figure 2.4.

Figure 2.4: Create Library (CRTLIB) Command Prompt Screen with Parameter Values Entered

Notice that even though the value for TEXT is a character-string constant, and as such must be enclosed in apostrophes ('); you do not need to enter the apostrophes here—the command prompter’s syntax checker inserts them for you automatically.

After you type in the necessary parameter values, you can press Enter to execute the command. If the values you enter are valid and the command is executed successfully, a message indicating a successful result is displayed, as you see at the bottom of the screen in Figure 2.5.

Figure 2.5: Message Indicating the CRTLIB Command Was Executed Successfully

All commands entered or prompted from a command line during an interactive session are maintained in a stack. To recall the most recently executed command, you can press the F9

(Retrieve command) function key on any screen that has a command line. You can recall an earlier command (one lower in the stack) by repeatedly pressing F9.

If you press F9 from the screen you see in Figure 2.5, the previous command (CRTLIB), including as many of its parameters as will fi t on the command line, is displayed in keyword notation (depending on the system value). Even if not all the parameters fi t, the values are not lost; if you request command prompting (F4) again, you will see the values displayed in

the command prompt screen’s entry fi elds. Figure 2.6 shows the result of pressing F9 after having successfully executed the CRTLIB command.

Figure 2.6: Results of Successfully Executed CRTLIB Command Retrieved by F9

Positional Notation

You can execute a command without using keywords; this method is referred to as positional notation. When you use positional notation, the order in which you specify parameters is very important. Positional notation works as long as

a. The values you enter for a particular parameter correspond exactly by position to the sequence of parameters as shown on the command prompt screen (or in the documentation at the IBM Information Center Web site, http://publib.boulder.ibm.

com/iseries).

b. You do not exceed the maximum number of positional parameters allowed for a particular command. (Each command has a maximum positional parameter attribute, which sets the limit for that command.)

To illustrate, if you wanted to create a test library named PAYROLL, you would need to supply the library name and specify the value *TEST for the Type parameter because *PROD

is the default value for Type. Using positional notation, you would correctly enter the command as

CRTLIB PAYROLL *TEST

But, if you changed the order of the parameter values without specifying keywords:

CRTLIB *TEST PAYROLL

the system would reject the command and issue the error message “Value ‘*TEST’ for

parameter LIB not a valid name.” In other words, without the keywords, the system

assumes that the value *TEST is for the fi rst parameter, which is Library, not Type.

Likewise, if you tried to create a production library named PAYROLL with a text description of “Production Lib” by entering the command

CRTLIB PAYROLL 'Production Lib'

the system would issue the error message “Production Lib not valid for parameter TYPE.” If you added the default value for the Type parameter, thinking you could then get the values in the correct relative positions, you might enter

CRTLIB PAYROLL *PROD 'Production Lib'

However, the system again would issue an error message, this time saying, “Number of

positional parameters exceeds limit of 2” (see the second rule above).

As you can see, using positional notation can be tricky. We suggest that, in general, and especially until you get used to the commands and parameters you use frequently, you should rely on command prompting and just enter or change the parameter values in the entry fi elds of the command prompt screen. As you gain experience, you will fi nd it more convenient to type commands directly on a command line without prompting—particularly for those commands that use the defaults or require you to enter only one parameter.

Do not worry too much about all these abbreviations and commands—there is no need to try to memorize a long list of them. We cover specifi c commands in more detail when we need to introduce them in the text and labs. The most productive time to study them is when you will be using them. You will be able to recall commands you use often without much effort. Remember, the IBM i OS has menus to help fi nd the commands you are looking for. Once you have found a command, you can easily get to a command prompt screen.