Difference between revisions of "F$TYPE"

From VSI OpenVMS Wiki
Jump to: navigation, search
(Created page with "'''F$TYPE''' is a lexical function that returns the data type of a symbol. The string INTEGER is returned if the symbol is equated to an integer, or if...")
 
(Examples: Added an example for an undefined symbol. Removed spurious prompt text from VMS HELP.)
 
Line 59: Line 59:
 
   TYPE = ""  
 
   TYPE = ""  
  
In this example, the F$TYPE function returns the string PROCESS_CONTEXT because the symbol has been produced by a call to the F$CONTEXT function with a context type of PROCESS. The symbol returns this type until F$CONTEXT is called with the symbol and the selection-item argument value CANCEL. LEXICALS F$TYPE Subtopic? LEXICALS Subtopic? Topic?
+
In this example, the F$TYPE function returns the string PROCESS_CONTEXT because the symbol has been produced by a call to the F$CONTEXT function with a context type of PROCESS. The symbol returns this type until F$CONTEXT is called with the symbol and the selection-item argument value CANCEL.
  
 +
$ TYPE = F$TYPE(UNDEF)
 +
$ SHOW SYMBOL TYPE
 +
  TYPE = ""
 +
 +
This example uses the F$TYPE function to determine that the symbol UNDEF is undefined. Because the symbol has not been set to a value, the F$TYPE function returns the empty string.
  
 
[[Category:Lexical Functions]]
 
[[Category:Lexical Functions]]

Latest revision as of 17:32, 9 October 2020

F$TYPE is a lexical function that returns the data type of a symbol. The string INTEGER is returned if the symbol is equated to an integer, or if the symbol is equated to a string whose characters form a valid integer. The string STRING is returned if the symbol is equated to a character string whose characters do not form a valid integer. If the symbol is undefined, a null string ("") is returned.

Syntax

F$TYPE(symbol-name)

Return Value

The string INTEGER is returned if the symbol is equated to an integer, or if the symbol is equated to a string whose characters form a valid integer.

If the symbol has been produced by a call to the F$CONTEXT function with a context type of PROCESS or by a call to the F$PID function, the string returned is PROCESS_CONTEXT. A symbol retains this type until F$CONTEXT is called with the symbol and the CANCEL keyword, or until a null string ("") is returned by a call to F$PID. Similarly, the return value is the string CLUSTER_SYSTEM_CONTEXT for symbols created by the F$CSID function. If the symbol is a context symbol, then the return value will be one of the types shown in the following table.

Symbol Type Lexical Creating Symbol
PROCESS_CONTEXT F$PID or F$CONTEXT (with PROCESS context type)
CLUSTER_SYSTEM_CONTEXT F$CSID

Arguments

symbol-name

Specifies the name of the symbol to be evaluated.

Examples

$ NUM = "52" 
$ TYPE = F$TYPE(NUM) 
$ SHOW SYMBOL TYPE 
  TYPE = "INTEGER" 

This example uses the F$TYPE function to determine the data type of the symbol NUM. NUM is equated to the character string "52". Because the characters in the string form a valid integer, the F$TYPE function returns the string INTEGER.

$ NUM = 52 
$ TYPE = F$TYPE(NUM) 
$ SHOW SYMBOL TYPE 
  TYPE = "INTEGER" 

In this example, the symbol NUM is equated to the integer 52. The F$TYPE function shows that the symbol has an integer data type.

$ CHAR = "FIVE" 
$ TYPE = F$TYPE(CHAR) 
$ SHOW SYMBOL TYPE 
  TYPE = "STRING" 

In this example, the symbol CHAR is equated to the character string FIVE. Because the characters in this string do not form a valid integer, the F$TYPE function shows that the symbol has a string value.

$ x = F$CONTEXT("PROCESS",CTX,"USERNAME","SMITH") 
$ TYPE = F$TYPE(CTX) 
$ SHOW SYMBOL TYPE 
  TYPE = "PROCESS_CONTEXT" 
$ x = F$CONTEXT("PROCESS",CTX,"CANCEL") 
$ TYPE = F$TYPE(CTX) 
$ SHOW SYMBOL TYPE 
  TYPE = "" 

In this example, the F$TYPE function returns the string PROCESS_CONTEXT because the symbol has been produced by a call to the F$CONTEXT function with a context type of PROCESS. The symbol returns this type until F$CONTEXT is called with the symbol and the selection-item argument value CANCEL.

$ TYPE = F$TYPE(UNDEF) 
$ SHOW SYMBOL TYPE 
  TYPE = "" 

This example uses the F$TYPE function to determine that the symbol UNDEF is undefined. Because the symbol has not been set to a value, the F$TYPE function returns the empty string.