Updated: 11 December 1998 |
OpenVMS DCL Dictionary
Previous | Contents | Index |
Returns the integer equivalent of the result of the specified expression.
F$INTEGER (expression)
expression
Specifies the expression to be evaluated. Specify either an integer or a character string expression.If you specify an integer expression, the F$INTEGER function evaluates the expression and returns the result. If you specify a string expression, the F$INTEGER function evaluates the expression, converts the resulting string to an integer, and returns the result.
After evaluating a string expression, the F$INTEGER function converts the result to an integer in the following way. If the resulting string contains characters that form a valid integer, the F$INTEGER function returns the integer value. If the string contains characters that do not form a valid integer, the F$INTEGER function returns the integer 1 if the string begins with T, t, Y, or y. The function returns the integer 0 if the string begins with any other character.
$ A = "23" $ B = F$INTEGER("-9" + A) $ SHOW SYMBOL B B = -923 Hex=FFFFFC65 Octal=176145 |
This example shows how to use the F$INTEGER function to equate a symbol to the integer value returned by the function. In the example, the F$INTEGER function returns the integer equivalent of the string expression ("--9" + A). First, the F$INTEGER function evaluates the string expression by concatenating the string literal "--9" with the string literal "23". Note that the value of the symbol A is substituted automatically in a string expression. Also note that the plus sign (+) is a string concatenation operator since both arguments are string literals.
After the string expression is evaluated, the F$INTEGER function converts the resulting character string ("--923") to an integer, and returns the value --923. This integer value is assigned to the symbol B.
Returns the length of the specified character string.
F$LENGTH (string)
string
Specifies the character string whose length is being determined. Specify the string argument as a character string expression.
$ MESSAGE = F$MESSAGE(%X1C) $ SHOW SYMBOL MESSAGE MESSAGE = "%SYSTEM-F-EXQUOTA, exceeded quota" $ STRING_LENGTH = F$LENGTH(MESSAGE) $ SHOW SYMBOL STRING_LENGTH STRING_LENGTH = 33 Hex = 00000021 Octal = 000041 |
The first assignment statement uses the F$MESSAGE function to return the message that corresponds to the hexadecimal value 1C. The message is returned as a character string and is assigned to the symbol MESSAGE.
The F$LENGTH function is then used to return the length of the character string assigned to the symbol MESSAGE. You do not need to use quotation marks (" ") when you use the symbol MESSAGE as an argument for the F$LENGTH function. (Quotation marks are not used around symbols in character string expressions.)
The F$LENGTH function returns the length of the character string and assigns it to the symbol STRING_LENGTH. At the end of the example, the symbol STRING_LENGTH has a value equal to the number of characters in the value of the symbol named MESSAGE, that is, 33.
Locates a specified portion of a character string and returns as an integer the offset of the first character. (An offset is the position of a character or a substring relative to the begining of the string. The first character in a string is always offset position 0 from the beginning of the string.)If the substring is not found, F$LOCATE returns the length (the offset of the last character in the character string plus one) of the searched string.
F$LOCATE (substring,string)
If the substring is not found, the F$LOCATE function returns an offset of the last character in the character string plus 1. (This equals the length of the string.)
substring
Specifies the character string that you want to locate within the string specified in the string argument.string
Specifies the character string to be edited by F$LOCATE.
#1 |
---|
$ FILE_SPEC = "MYFILE.DAT;1" $ NAME_LENGTH = F$LOCATE(".",FILE_SPEC) |
The F$LOCATE function in this example returns the position of the period (.) in the string with respect to the beginning of the string. The period is in offset position 6, so the value 6 is assigned to the symbol NAME_LENGTH. Note that NAME_LENGTH also equals the length of the file name portion of the file specification MYFILE.DAT, that is, 6.
The substring argument, the period, is specified as a string literal and is therefore enclosed in quotation marks (" "). The string argument FILE_SPEC is a symbol, so it should not be placed within quotation marks. It is automatically replaced by its current value during the processing of the function.
#2 |
---|
$ INQUIRE TIME "Enter time" $ IF F$LOCATE(":",TIME) .EQ. F$LENGTH(TIME) THEN - GOTO NO_COLON |
This section of a command procedure compares the results of the F$LOCATE and F$LENGTH functions to see if they are equal. This technique is commonly used to determine whether a character or substring is contained in a string.
In the example, the INQUIRE command prompts for a time value and assigns the user-supplied time to the symbol TIME. The IF command checks for the presence of a colon (:) in the string entered in response to the prompt. If the value returned by the F$LOCATE function equals the value returned by the F$LENGTH function, the colon is not present. You use the .EQ. operator (rather than .EQS.) because the F$LOCATE and F$LENGTH functions return integer values.
Note that quotation marks are used around the substring argument, the colon, because it is a string literal. However, the symbol TIME does not require quotation marks because it is automatically evaluated as a string expression.
Returns as a character string the facility, severity, identification, and text associated with the specified system status code.
F$MESSAGE (status-code[,message-component-list])
Note that, although each message in the system message file has a numeric value or range of values associated with it, there are many possible numeric values that do not have corresponding messages. If you specify an argument that has no corresponding message, the F$MESSAGE function returns a string containing the NOMSG error message.
For more information on system error messages, refer to the OpenVMS System Messages: Companion Guide for Help Message Users.
status-code
Specifies the status code for which you are requesting error message text. You must specify the status code as an integer expression.message-component-list
Specifies the system message component for which information is to be returned. If this parameter is null or unspecified, then all system message components are returned.Table DCLI-13 describes the valid system message component keywords:
Table DCLI-13 F$MESSAGE Keywords Component Keyword Information Returned FACILITY Facility name SEVERITY Severity level indicator IDENT Abbreviation of message text TEXT Explanation of message Note that when the FACILITY, SEVERITY, and IDENT code keywords are specified (individually or in combination), the resulting message code is prefaced with the percent (%) character. The individual parts of the message code are separated by hyphens when multiple code keywords are specified.
When only the TEXT keyword is specified, the resulting text is not prefaced with any character. When the TEXT keyword is specified with the FACILITY, SEVERITY, or IDENT code keyword, the message code is separated from the text by a combination of a comma and a blank (, ).
$ ERROR_TEXT = F$MESSAGE(%X1C) $ SHOW SYMBOL ERROR_TEXT ERROR_TEXT = "%SYSTEM-F-EXQUOTA, exceeded quota" |
This example shows how to use the F$MESSAGE function to determine the message associated with the status code %X1C. The F$MESSAGE function returns the message string, which is assigned to the symbol ERROR_TEXT.
$ SUBMIT IMPORTANT.COM $ SYNCHRONIZE /entry='$ENTRY' $ IF $STATUS THEN EXIT $! $ JOB_STATUS = $STATUS $! $ IF "%JOBDELETE" .EQS. F$MESSAGE (JOB_STATUS, "IDENT") $ THEN . . . $ ELSE $ IF "%JOBABORT" .EQS. F$MESSAGE (JOB_STATUS, "IDENT") $ THEN . . . $ ELSE $ . . . $ ENDIF $ ENDIF . . . |
This command procedure submits a batch job and waits for it to complete. Upon successful completion, the procedure exits. If the job completes unsuccessfully, more processing is done based on the termination status of the batch job.
The first command submits the command procedure IMPORTANT.COM. In the second command, the SYNCHRONIZE command tells the procedure to wait for the job to finish. The third command determines if the job completed successfully and, if so, the procedure exits. The next command saves the status in a symbol.
The first IF statement uses F$MESSAGE to determine whether the job was deleted before execution. If so, it does some processing, possibly to resubmit the job or to inform a user via MAIL.
The next IF statement uses F$MESSAGE to determine whether the job was deleted during execution. As a result, some cleanup or human intervention may be required, which would be done in the THEN block.
If neither IF statement was true, then some other unsuccessful status was returned. Other processing, which would be done in the block following the ELSE statement, might be required.
Returns a character string showing the mode in which a process is executing. The F$MODE function has no arguments, but must be followed by parentheses.
F$MODE()
None.
The lexical function F$MODE returns a character string showing the mode in which a process is executing. The F$MODE function has no arguments, but must be followed by parentheses.The F$MODE function is useful in command procedures that must operate differently when executed interactively and noninteractively. You should include either the F$MODE function or the F$ENVIRONMENT function in your login command file to execute different commands for interactive terminal sessions and noninteractive sessions.
If you do not include the F$MODE function to test whether your login command file is being executed from an interactive process, and the login command file is executed from a noninteractive process (such as a batch job), the process may terminate if the login command file contains commands that are appropriate only for interactive processing.
A command procedure can use the F$MODE function to test whether the procedure is being executed during an interactive terminal session. It can direct the flow of execution according to the results of this test.
$ IF F$MODE() .NES. "INTERACTIVE" THEN GOTO NON_INT_DEF $ INTDEF: ! Commands for interactive terminal sessions . . . $ EXIT $ NON_INT_DEF: !Commands for noninteractive processes . . . |
This example shows the beginning of a login.com file that has two sets of initialization commands: one for interactive mode and one for noninteractive mode (including batch and network jobs). The IF command compares the character string returned by F$MODE with the character string INTERACTIVE; if they are not equal, control branches to the label NON_INT_DEF. If the character strings are equal, the statements following the label INTDEF are executed and the procedure exits before the statements at NON_INT_DEF.
Parses a file specification and returns either the expanded file specification or the particular file specification field that you request.
F$PARSE (filespec [,default-spec] [,related-spec] [,field] [,parse-type])
In most cases, the F$PARSE function returns a null string ("") if an error is detected during the parse. For example, a null string is returned if the file specification has incorrect syntax or if a disk or directory does not exist, making the file specification logically incorrect. However, when you specify a field name or the SYNTAX_ONLY parse type, F$PARSE returns the appropriate information.
filespec
Specifies a character string containing the file specification to be parsed.The file specification can contain the asterisk (*) and the percent sign (%) wildcard characters. If you use a wildcard character, the file specification returned by the F$PARSE function contains the wildcard.
default-spec
Specifies a character string containing the default file specification.The fields in the default file specification are substituted in the output string if a particular field in the filespec argument is missing. You can make further substitutions in the filespec argument by using the related-spec argument.
related-spec
Specifies a character string containing the related file specification.The fields in the related file specification are substituted in the output string if a particular field is missing from both the filespec and default-spec arguments.
field
Specifies a character string containing the name of a field in a file specification. Specifying the field argument causes the F$PARSE function to return a specific portion of a file specification.Specify one of the following field names (do not abbreviate):
NODE Node name DEVICE Device name DIRECTORY Directory name NAME File name TYPE File type VERSION File version number parse-type
Specifies the type of parsing to be performed. By default, the F$PARSE function verifies that the directory in the file specification exists on the device in the file specification. However, the existence of the directory is not verified if you provide a field argument. Note that the device and directory can be explicitly given in one of the arguments, or can be provided by default.Also, by default the F$PARSE function translates logical names if they are provided in any of the arguments. The F$PARSE function stops iterative translation when it encounters a logical name with the CONCEALED attribute.
You can change how the F$PARSE function parses a file specification by using one of the following keywords:
NO_CONCEAL Ignores the "conceal" attribute in the translation of a logical name as part of the file specification; that is, logical name translation does not end when a concealed logical name is encountered. SYNTAX_ONLY The syntax of the file specification is checked without verifying that the specified directory exists on the specified device.
The F$PARSE function parses file specifications by using the RMS service $PARSE. For more information on the $PARSE service, refer to the OpenVMS Record Management Services Reference Manual.When you use the F$PARSE function, you can omit those optional arguments to the right of the last argument you specify. However, you must include commas (,) as placeholders if you omit optional arguments to the left of the last argument you specify.
If you omit the device and directory names in the filespec argument, the F$PARSE function supplies defaults, first from the default-spec argument and second from the related-spec argument. If names are not provided by these arguments, the F$PARSE function uses your current default disk and directory.
If you omit the node name, the file name, the file type, or the version number, the F$PARSE function supplies defaults, first from the default-spec argument and second from the related-spec argument. (Note that the version number is not picked up from the related-spec argument.) If names are not provided by these arguments, the F$PARSE function returns a null specification for these fields.
#1 |
---|
$ SET DEF DISK2:[FIRST] $ SPEC = F$PARSE("JAMES.MAR","[ROOT]",,,"SYNTAX_ONLY") $ SHOW SYMBOL SPEC SPEC = "DISK2:[ROOT]JAMES.MAR;" |
In this example, the F$PARSE function returns the expanded file specification for the file JAMES.MAR. The example uses the SYNTAX_ONLY keyword to request that F$PARSE check the syntax, but should not verify that the [ROOT] directory exists on DISK2.
The default device and directory are DISK2:[FIRST]. Because the directory name [ROOT] is specified as the default-spec argument in the assignment statement, it is used as the directory name in the output string. Note that the default device returned in the output string is DISK2, and the default version number for the file is null. You must place quotation marks (" ") around the arguments JAMES.MAR and ROOT because they are string literals.
If you had not specified syntax-only parsing, and [ROOT] were not on DISK2, a null string would have been returned.
#2 |
---|
$ SET DEFAULT DB1:[VARGO] $ SPEC = F$PARSE("INFO.COM",,,"DIRECTORY") $ SHOW SYMBOL SPEC SPEC = "[VARGO]" |
In this example the F$PARSE function returns the directory name of the file INFO.COM. Note that because the default-spec and related-spec arguments are omitted from the argument list, commas (,) must be inserted in their place.
#3 |
---|
$ SPEC= F$PARSE("DENVER::DB1:[PROD]RUN.DAT",,,"TYPE") $ SHOW SYMBOL SPEC SPEC = ".DAT" |
In this example, the F$PARSE function is used to parse a file specification containing a node name. The F$PARSE function returns the file type .DAT for the file RUN.DAT at the remote node DENVER.
Returns a process identification (PID) number and updates the context symbol to point to the current position in the system's process list.
F$PID (context-symbol)
context-symbol
Specifies a symbol that DCL uses to store a pointer into the system's list of processes. The F$PID function uses this pointer to return a PID.Specify the context symbol by using a symbol. The first time you use the F$PID function in a command procedure, you should use a symbol that is either undefined or equated to the null string ("") or a context symbol that has been created by the F$CONTEXT function.
If the context symbol is undefined or equated to a null string, the F$PID function returns the first PID in the system's process list that it has the privilege to access. That is, if you have GROUP privilege and if the context symbol is null or undefined, the F$PID function returns the PID of the first process in your group. If you have WORLD privilege, the F$PID function returns the PID of the first process in the list. If you have neither GROUP nor WORLD privilege, the F$PID returns the first process that you own. Subsequent calls to F$PID return the rest of the processes on the system you are accessing.
If the context symbol has been created by the F$CONTEXT function, the F$PID function returns the first process name in the system's process list that fits the criteria specified in the F$CONTEXT calls. Subsequent calls to F$PID return only the PIDs of those processes that meet the selection criteria set up by the F$CONTEXT function and that are accessible to your current privileges.
The F$PID function returns a process identification (PID) number and updates the context symbol to point to the current position in the system's process list. You can step through all the processes on a system, or use the lexical function F$CONTEXT to specify selection criteria. The function F$CONTEXT is not required.The PIDs returned by the F$PID function depend on the privilege of your process. If you have GROUP privilege, the F$PID function returns PIDs of processes in your group. If you have WORLD privilege, the F$PID function returns PIDs of all processes on the system. If you lack GROUP or WORLD privilege, the F$PID function returns only those processes that you own.
The F$CONTEXT function enables the F$PID function to retrieve processes from any node in a dual-architecture OpenVMS Cluster system.
The first time you use the F$PID function, use a symbol that is either undefined or equated to the null string or to a context symbol that has been created by the F$CONTEXT function. This causes the F$PID function to return the first PID in the system's process list that you have the privilege to access. It also causes the F$PID function to initialize the context-symbol argument.
Once the context-symbol argument is initialized, each subsequent F$PID returns the next PID in sequence, using the selection criteria set up by the F$CONTEXT function, if any, and updates the context symbol. After the last PID in the process list is returned, the F$PID function returns a null string.
$ CONTEXT = "" $ START: $ PID = F$PID(CONTEXT) $ IF PID .EQS. "" THEN EXIT $ SHOW SYMBOL PID $ GOTO START |
This command procedure uses the F$PID function to display a list of PIDs. The assignment statement declares the symbol CONTEXT, which is used as the context-symbol argument for the F$PID function. Because CONTEXT is equated to a null string, the F$PID function returns the first PID in the process list that it has the privilege to access.
The PIDs displayed by this command procedure depend on the privilege of your process. When run with GROUP privilege, the PIDs of users in your group are displayed. When run with WORLD privilege, the PIDs of all users on the system are displayed. Without GROUP or WORLD privilege, only those processes that you own are displayed.
Previous | Next | Contents | Index |
Copyright © Compaq Computer Corporation 1998. All rights reserved. Legal |
9996PRO_034.HTML
|