Difference between revisions of "Lexical functions"

From VSI OpenVMS Wiki
Jump to: navigation, search
(See also)
m (Corrected minor error. "Note that you must use the brackets..." changed to "Note that you must use the parentheses...")
 
(7 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
F$function-name([args,...])
 
F$function-name([args,...])
  
Note that you must use the brackets 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.
+
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 by topic=
Line 13: Line 13:
 
==Conversion and data types==
 
==Conversion and data types==
 
* [[F$STRING()]] returns the string equivalent of the result of the specified expression.
 
* [[F$STRING()]] returns the string equivalent of the result of the specified expression.
<pre>$ write sys$output f$string(5)
+
<nowiki>
5</pre>
+
$ A = F$STRING(5)
 +
$ SHOW SYM A
 +
  A = "5"
 +
</nowiki>
 
* [[F$INTEGER()]] returns the integer equivalent of the result of the specified expression.
 
* [[F$INTEGER()]] returns the integer equivalent of the result of the specified expression.
 
<pre>$ write sys$output f$integer("y")
 
<pre>$ write sys$output f$integer("y")
Line 50: Line 53:
 
* [[F$EXTRACT()]] extracts a substring from a character string expression.
 
* [[F$EXTRACT()]] extracts a substring from a character string expression.
  
<pre>$ WRITE SYS$OUTPUT F$EXTRACT("1,2,"HELLO")
+
<pre>$ WRITE SYS$OUTPUT F$EXTRACT("1",2,"HELLO")
 
EL
 
EL
 
</pre>
 
</pre>
Line 63: Line 66:
 
hello</pre>
 
hello</pre>
  
 +
* [[F$MATCH_WILD()]] performs a wildcard matching between a candidate and a pattern string.
  
 
==Files==
 
==Files==
Line 93: Line 97:
  
 
==Logical names==
 
==Logical names==
[[F$TRNLNM()]] used for translating logical names and obtaining their attributes.
+
[[F$TRNLNM()]] used for translating [[Logical Name|logical names]] and obtaining their attributes.
  
 
==User environment==
 
==User environment==
Line 104: Line 108:
 
* [[F$ENVIRONMENT()]] obtains information about the DCL command environment.
 
* [[F$ENVIRONMENT()]] obtains information about the DCL command environment.
 
* [[F$DIRECTORY()]] returns the current [[Default directory|default]] directory name string.
 
* [[F$DIRECTORY()]] returns the current [[Default directory|default]] directory name string.
 +
 
===Privileges===
 
===Privileges===
* [[F$SETPRV()]] sets the specified [[User privileges|privileges]] and returns a list of keywords indicating the previous state of these privileges for the current process.
+
* [[F$SETPRV()]] sets the specified [[Privileges|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.
 
* [[F$PRIVILEGE()]] returns a value of TRUE or FALSE depending on whether your current process privileges match the privileges listed in the argument.
  
==Miscellaneous===
+
==Licenses==
* [[F$MATCH_WILD()]] performs a wildcard matching between a candidate and a pattern string.
+
* [[F$LICENSE()]] checks whether the specified [[Licensing|license]] is loaded on the system.
* [[f$LICENSE()]] checks whether the specified [[Licensing|license]] is loaded on the system.
 

Latest revision as of 17:24, 7 January 2020

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