HPlogo MPE/iX Commands Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 3  Command Definitions C-E

CALC

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Evaluates an expression. (Native Mode)

Syntax

CALC expression

NOTE: This command follows the optional MPE/iX command line syntax. Refer to "Optional Format for MPE/iX Commands" at the beginning of this chapter.

Parameters

expression

The expression to be evaluated.

Operation Notes

The CALC command evaluates expression and displays the result to $STDLIST. Expressions can yield integer, string, or Boolean results. Integer results are displayed in decimal, hexadecimal ($ prefix), and octal (% prefix) notations. Boolean expressions are displayed as TRUE or FALSE. The variable HPRESULT is set to the result of the last expression evaluated by CALC. The type of HPRESULT changes depending on the type of result generated by CALC.

Table 3-1 “Logical Operators - The CALC Command” lists some of the logical operators for the CALC command. Enter :HELP expressions for more information

Table 3-1 Logical Operators - The CALC Command

Logical operators:AND, OR, XOR, NOT
Boolean functions and values:BOUND, TRUE, FALSE, ALPHA, ALPHANUM, NUMERIC, ODD
Comparison operators:=, <>, <, >, <=, >=
Bit manipulation operators:LSL, LSR, CSR, CSL, BAND, BOR, BXOR, BNOT
Arithmetic operators:MOD, ABS, * , / , + , -, ^ (exponentiation)
Functions returning strings:CHR, DWNS, UPS, HEX, OCTAL, INPUT, LFT, RHT, RPT, LTRIM, RTRIM, STR
Functions returning integers:ABS, LEN, MAX, MIN, ORD, POS, TYPEOF
Other functions:FINFO, SETVAR

 

The operands you may use are any variable, integer, string, Boolean constant, or the system-reserved words WARN, FATAL, SYSTEM, and OK. You may form compound logical expressions using the AND, NOT, XOR, and OR logical operators, optionally nested within parentheses.

Do not use the FINFO function with the CALC command for remote files. It ignores their existence and returns incorrect information.

Use

This command is available in a session, job, program, or in BREAK. Pressing Break terminates the INPUT( ) function.

Example

The result of CALC sample depends on the value entered for sample and on the type of the value, as shown in Table 3-2 “Results of CALC”

Table 3-2 Results of CALC

sampleDisplayed (HPRESULT)Type
5*10-743, $2B, %53Integer
LEN("abc")3, $3, %3Integer
UPS("Abc")ABCString
1=1TRUEBoolean
MAX(1,0,abs(-12),10)12, $c, %14Integer

 

Related Information

Commands

DELETEVAR, ELSEIF, IF, SETJCW, SETVAR, SHOWJCW, SHOWVAR, WHILE

Manuals

Appendix B, "Expression Evaluator Functions"

Command Interpreter Access and Variables Programmer's Guide

Feedback to webmaster