Skip to main content

$PRINCIPAL

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

  • USE command

  • $IO special variable

FeedbackOpens in a new tab