home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / old / ckermit5a190 / cketest.ini < prev    next >
Text File  |  2020-01-01  |  4KB  |  186 lines

  1. COMMENT - CKETEST.INI
  2. ;
  3. ; Exercises C-Kermit's programming constructs (see Ch.12, "Using C-Kermit").
  4. ;
  5. echo
  6. echo C-Kermit Programming-Constructs Test
  7. echo
  8. echo If you don't see the message "Proceeding..."
  9. echo on the next line, C-Kermit was not configured for script programming.
  10. check if
  11. echo Proceeding...
  12. sleep 2
  13. echo
  14. asg \%p ckedemo.ini
  15. if exist \%p goto demo
  16. ;
  17. ; If ckedemo.ini is not in the current directory, we have to find it...
  18. ;
  19. asg \%s /            ; Directory separator
  20. if eq \v(system) VMS asg \%s ]
  21. if eq \v(system) AOS/VS asg \%s :
  22. if eq \v(system) Macintosh asg \%s :
  23. if eq \v(system) Atari_ST asg \%s \\
  24. if eq \v(system) Stratus_VOS >
  25.  
  26. asg \%p \freverse(\v(cmdfile))
  27. asg \%p \freverse(\fsubstr(\%p,\findex(/,\%p)))ckedemo.ini
  28. if exist \%p goto demo
  29. echo Can't find ckedemo.ini file, proceeding with other tests...
  30. goto other
  31.  
  32. :DEMO
  33. take \%p
  34. ec Spelling some numbers...
  35. for \%i 0 9 1 { spellnum \%i }
  36.  
  37. echo Calculator demo...
  38. calc
  39.  
  40. echo Adding machine demo - Enter an empty line to quit...
  41. addingmachine
  42.  
  43. echo Recursive sum macro...
  44.  
  45. def sum if not def \%1 return,-  ; Make sure there is an argument
  46.   if not numeric \%1 return,-    ; Make sure argument is numeric
  47.   if not > \%1 0 return,-        ; Make sure argument is positive
  48.   if = \%1 1 return 1,-          ; If argument is 1, the sum is 1
  49.   else return \feval(\%1 + \fexecute(sum \feval(\%1 - 1)))
  50.  
  51. def addemup echo sum of 0..\%1 = \fexec(sum \%1)
  52. addemup 1
  53. addemup 2
  54. addemup 3
  55. addemup 4
  56. addemup 5
  57. addemup 10
  58. addemup 20
  59.  
  60. :LOOP
  61. echo
  62. ask \%1 { Type 3 numbers separated by spaces or an empty line to quit:  }
  63. if not def \%1 goto other
  64. smallest \%1
  65. goto loop
  66.  
  67. :OTHER                ; Other tests
  68.  
  69. echo WHILE-LOOP TEST...
  70. echo You should see:
  71. echo { 0 1 2 3 4}
  72. def \%a 0
  73. while < \%a 5 { write scr { \%a}, incr \%a }
  74. echo
  75.  
  76. echo NESTED WHILE-LOOP TEST...
  77. echo You should see:
  78. echo { 0:0 0:1 0:2 1:0 1:1 1:2 2:0 2:1 2:2}
  79. def \%a 0
  80. while < \%a 3 {-
  81.   def \%b 0,-
  82.   while < \%b 3 {-
  83.     write scr { \%a:\%b},-
  84.     incr \%b,-
  85.   },-
  86.   incr \%a -
  87. }
  88. echo
  89.  
  90. echo FOR-LOOP INSIDE WHILE-LOOP
  91. echo You should see:
  92. echo { 1:1 1:2 1:3 2:1 2:2 2:3 3:1 3:2 3:3}
  93. def \%a 1
  94. while < \%a 4 { -
  95.   for %i 1 3 1 { write scr { \%a:\%i} },-
  96.   inc \%a -
  97. }
  98. echo
  99.  
  100. echo WHILE-LOOP INSIDE FOR-LOOP
  101. echo You should see:
  102. echo { 1:1 1:2 1:3 2:1 2:2 2:3 3:1 3:2 3:3}
  103. for \%i 1 3 1 {-
  104.   def \%a 1,-
  105.   while < \%a 4 {-
  106.     writ scr { \%i:\%a},-
  107.     incr \%a -
  108.   }-
  109. }
  110. echo
  111.  
  112. echo NESTED FOR LOOP TEST
  113. echo You should see:
  114. echo { 1:1 1:2 1:3 2:2 2:3 3:3}
  115. for \%i 1 3 1 {-
  116.   for \%j \%i 3 1 {-
  117.     write scr { \%i:\%j} -
  118.   }-
  119. }
  120. echo
  121.  
  122. echo NESTED FOR/WHILE/BREAK/CONTINUE TEST 
  123. echo You should see:
  124. echo { 1:1 1:3 3:1 3:3}
  125. for \%i 1 4 1 { -
  126.   if = \%i 2 continue,-
  127.   else if = \%i 4 break,-
  128.   asg \%j 0,-
  129.   while < \%j 4 { -
  130.     incr \%j,-
  131.     if = \%j 2 continue,-
  132.     else if = \%j 4 break,-
  133.     write screen { \%i:\%j} -
  134.   },-
  135. }
  136. echo
  137.  
  138. echo END from inside nested FOR loops (Edit 190 and later)
  139. echo You should see:
  140. echo { 1:1 1:2 1:3 2:1 2:2 2:3 3:1}
  141. define xx -
  142.   for \%i 1 3 1 {-
  143.     for \%j 1 3 1 {-
  144.       write scr { \%i:\%j}, -
  145.       if = \%i 3 if = \%j 1 end -
  146.     }-
  147.   }
  148. do xx
  149. echo
  150.  
  151. echo RETURN from inside nested FOR loops (Edit 190 and later)
  152. echo You should see "IT WORKS":
  153. define xx -
  154.   for \%i 1 3 1 { -
  155.     for \%j 1 3 1 { -
  156.       if = \%i 3 if = \%j 1 return IT \%1 -
  157.     } -
  158.   } -
  159.   echo YOU SHOULD NOT SEE THIS
  160. echo "\fexec(xx WORKS)"
  161.  
  162. echo END message from inside XIF (Edit 190 and later)
  163. echo You should see "IT WORKS"
  164. def xx xif = 1 1 { end 0 "IT \%1"}
  165. xx WORKS
  166.  
  167. echo Grouping of words in IF EQUAL (Edit 190 and later)
  168. echo You should see "IT WORKS":
  169. def \%a one two three
  170. if equal {\%a} {one two three} echo IT WORKS
  171. else echo It doesn't work, foo.
  172. ec
  173. ec MINPUT test...
  174. ec Please type one of the following (without the number):
  175. ec 1. ab cd
  176. ec 2. abcd
  177. ec 3. xyz
  178. ec You have 20 seconds...
  179. minput 20 {ab cd} abcd xyz
  180. ec
  181. if success echo You typed Number \v(minput).
  182. else echo You did not type any of them within the time limit.
  183. echo
  184. echo End of \v(cmdfile)
  185. echo
  186.