Lexical functions

From VSI OpenVMS Wiki
Jump to: navigation, search

Lexical functions are constructs that return information about your OpenVMS system and arithmetic and string expressions and perform other functions. There are 43 lexical functions in OpenVMS 8.4-L2.

Format

F$function-name([args,...])

Note that you must use the parentheses even if no arguments are required. Sometimes it is required to specify an empty string ("") as an argument, and sometimes they follow a specific order and you need to keep the commas in place if you omit certain arguments.

Lexical functions by topic

Lexical functions serve a number of purposes: unit, data type, datetime conversion, returning information about system objects and establishing context for such information, etc.

Conversion and data types

  • F$STRING() returns the string equivalent of the result of the specified expression.
$ A = F$STRING(5)
$ SHOW SYM A
  A = "5"
 
  • F$INTEGER() returns the integer equivalent of the result of the specified expression.
$ write sys$output f$integer("y")
1
$ write sys$output f$integer("a")
0
  • F$IDENTIFIER() converts an identifier in named format to its integer equivalent, or vice versa.
$ WRITE SYS$OUTPUT F$IDENTIFIER("SLOANE","NAME_TO_NUMBER")
15728665
  • F$CUNITS converts a number from one specified unit of measure to another.
  • F$CVUI extracts bit fields from character string data and converts the result, as an unsigned value, to an integer.
  • F$CVSI() extracts bit fields from character string data and converts the result, as a signed value, to an integer.
  • F$TYPE determines the data type of a symbol

String operations

  • F$LOCATE() locates a character or character substring within a string and returns its offset within the string.
$ WRITE SYS$OUTPUT F$LOCATE("E","HELLO")
1
  • F$LENGTH() returns the length of a specified string.
$ WRITE SYS$OUTPUT F$LENGTH("HELLO")
5
  • F$FAO() converts the specified control string to a formatted ASCII output string.
$ WRITE SYS$OUTPUT F$FAO("!5SL !5UB !5SL",-1,2,"pcs")
   -1     2   pcs

$ REPORT = F$FAO("There !0UL!1%Cis!%Eare!%F !-!UL !-!0UL!1%Cchild!%Echildren!%F here",OFFSPRING)
$ SHOW SYMBOL REPORT
$ REPORT ="There is 1 child here"
  • F$EXTRACT() extracts a substring from a character string expression.
$ WRITE SYS$OUTPUT F$EXTRACT("1",2,"HELLO")
EL
  • F$ELEMENT() extracts an element from a string in which the elements are separated by a specified delimiter.
$ WRITE SYS$OUTPUT F$ELEMENT(0,"/","1/2/3")
1
  • F$EDIT() edits a character string based on the edits specified (upcases, removes spaces and comments).
$ WRITE SYS$OUTPUT F$EDIT("    HELLO  ","COLLAPSE,LOWERCASE")
hello
  • F$MATCH_WILD() performs a wildcard matching between a candidate and a pattern string.

Files

  • F$SEARCH() looks for the file you specify
  • F$PARSE() invokes the $PARSE RMS service to parse a file specification and return either the expanded file specification or the particular file specification field that you request.
  • F$FILE_ATTRIBUTES() returns attribute information for a specified file.
  • F$FID_TO_NAME() translates a file identification to a file specification.

Processes

Devices

Time

  • F$TIME() returns the current date and time of day, in the format dd-mmm-yyyy hh:mm:ss.cc.
  • F$DELTA_TIME() returns the time difference between a given start and end time.
  • F$CVTIME() retrieves information about an absolute, combination, or delta time string.

System and cluster

  • F$GETSYI() returns status and identification information about the local system, or about a node in the local cluster, if your system is part of a cluster.
  • F$CSID() returns an OpenVMS Cluster identification number and updates the context symbol to point to the current position in the system's cluster node list.

Queues

  • F$GETQUI() returns information about queues, batch and print jobs currently in those queues, form definitions, and characteristic definitions kept in the queue database.

Logical names

F$TRNLNM() used for translating logical names and obtaining their attributes.

User environment

  • F$USER() returns the current user's UIC
  • F$VERIFY() returns the integer 1 if command procedure verification is set on; returns the integer 0 if command procedure verification is set off. The F$VERIFY function also can set new verification states.
  • F$PROCESS() returns the current process name string.
  • F$MODE() shows the mode in which a process is executing.
  • F$MESSAGE() returns the message text associated with a specified system status code value.
  • F$GETENV() returns the value of the specified console environment variable.
  • F$ENVIRONMENT() obtains information about the DCL command environment.
  • F$DIRECTORY() returns the current default directory name string.

Privileges

  • F$SETPRV() sets the specified privileges and returns a list of keywords indicating the previous state of these privileges for the current process.
  • F$PRIVILEGE() returns a value of TRUE or FALSE depending on whether your current process privileges match the privileges listed in the argument.

Licenses