mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-18 06:07:29 +00:00
38 lines
737 B
Plaintext
38 lines
737 B
Plaintext
|
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
|