docs.intersystems.com
Home / ObjectScript Reference / ObjectScript Special Variables / $PRINCIPAL


ObjectScript Reference
$PRINCIPAL
Previous section           Next section
InterSystems: The power behind what matters   
Search:  


Contains the ID of the principal I/O device.
Synopsis
$PRINCIPAL
$P
Description
$PRINCIPAL contains the ID of the principal I/O device for the current process. $PRINCIPAL operates like $IO. Refer to $IO for details of specific device types and system platforms.
If the principal device is closed, $PRINCIPAL does not change. If the principal input and output devices differ, $PRINCIPAL reflects the ID of the principal input device.
This special variable cannot be modified using the SET command. Attempting to do so results in a <SYNTAX> error.
Examples
This example uses $PRINCIPAL to test for a principal device.
   IF $PIECE($PRINCIPAL,"|",4) {
     WRITE "Principal device is: ",$PRINCIPAL }
   ELSE  { WRITE "Undefined" }
This example uses and writes to the principal device.
   USE $PRINCIPAL 
   WRITE "output to $PRINCIPAL"
Notes
$PRINCIPAL and USE 0
$PRINCIPAL is functionally equivalent to the widely used, but nonstandard, USE 0. Use $PRINCIPAL instead of USE 0 because it is standard, and because it makes your code more flexible.
See Also


Previous section           Next section
View this book as PDF
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-02-21 01:13:32