A2osX/TESTS/FORTEST.txt

74 lines
1.5 KiB
Plaintext
Raw Normal View History

2019-03-07 02:13:28 +00:00
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."
2019-03-07 02:13:28 +00:00
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"
2019-03-07 02:13:28 +00:00
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
2019-03-07 02:13:28 +00:00
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
2019-03-07 02:13:28 +00:00
MAN
TEXT /MAKE/USR/SHARE/TESTS/FORTEST