A2osX/TESTS/FORTEST.txt

74 lines
1.5 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
PREFIX
AUTO 4,1
#!/BIN/SH
#
# This script tests the new FOR NEXT loop construct.
#
echo "\f\n\n FOR NEXT Tests"
echo "\n\nThis script tests the FOR var IN EXP construct"
echo "EXP can be a string of words separated by spaces, a file"
echo "or the results of a command."
echo
IF [ -N $Log ]
ECHO "Begin FOR NEXT Tests" >> ${Log}
ELSE
SET T = 0
SET F = 0
SET P = 0
FI
SET LIST = "0 22 44 -55 14.7 1234.4321"
SET COUNT = 0
SET TOTAL = 0
FOR ITEM IN $LIST
ECHO $ITEM
SET COUNT = $COUNT + 1
SET TOTAL = $TOTAL + $ITEM
NEXT
ECHO "I counted $COUNT items"
ECHO "with a total of $TOTAL"
SET LIST = "1000 4567 -999 -9999 42 59000 -110000 60000 14"
SET COUNT = 0
SET TOTAL = 0
FOR ITEM IN $LIST
ECHO $ITEM
SET COUNT = $COUNT + 1
SET TOTAL = $TOTAL + $ITEM
NEXT
ECHO "I counted $COUNT items"
ECHO "with a total of $TOTAL"
SET LIST = "Remy Patrick Adam Admin Zeus Zero"
SET COUNT = 0
FOR ITEM IN $LIST
ECHO $ITEM
SET COUNT = $COUNT + 1
NEXT
ECHO "I counted $COUNT items"
SET LIST = "Remy | Patrick! Adam @ Admin Zeus &Zero *-As"
SET COUNT = 0
FOR ITEM IN $LIST
ECHO $ITEM
SET COUNT = $COUNT + 1
NEXT
ECHO "I counted $COUNT items"
EXIT
SET OL = $COUNT - 1
SET SLIST = ""
WHILE [ $OL -ne 0 ]
SET ITEM1 =
FOR ITEM IN $LIST
ECHO $OL $ITEM
IF [ -N $ITEM1 ]
SET ITEM1 = $ITEM
ELSE
IF [ $ITEM1
FI
NEXT
SET OL = $OL - 1
LOOP
MAN
TEXT /MAKE/USR/SHARE/TESTS/FORTEST