A2osX/EXAMPLES/EXITDEMO.txt

38 lines
737 B
Plaintext
Raw Normal View History

2019-11-24 03:07:04 +00:00
NEW
PREFIX
AUTO 4,1
#!/BIN/SH
#
# EXIT Command Examples
#
# This example shows the use of EXIT from a function with a return code
#
FUNCTION DIVIDE
{
IF ![ -I $A ] OR ![ -I $B ]
# Error not vars not integers
EXIT 3
FI
IF [ $B -EQ 0 ]
# Error Zero Divisor
EXIT 7
FI
SET $3 = $A / $B
}
READ -P "\nEnter a number: " A
READ -P "\nAnother number: " B
CALL DIVIDE $A $B C
SWITCH $?
CASE 0
ECHO "\n$A divided by $B is $C\n"
BREAK
CASE 3
ECHO "\nError: Input not Integers\n"
BREAK
CASE 7
ECHO "\nError: Divide by Zero Prohibitied\n"
BREAK
END
MAN
TEXT /MAKE/USR/SHARE/EXAMPLES/EXITDEMO