Advertisement
Mesaif

CH4_Ex7

May 11th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. %Counts back by 1 from an inputted number and gives a special message upon further iterations of the loop
  2. %VARIABLES
  3. var num : int
  4. var loopcount : int := 1
  5.  
  6. %PROCEDURES
  7. procedure countBack
  8. for decreasing i : num .. 1 by 1
  9. put i, " " ..
  10. delay (500)
  11. end for
  12. end countBack
  13. %Main loop
  14. loop
  15.  
  16. %Give a special number if the loop has executed more than once
  17. if loopcount = 1 then
  18. put "Number to start at: " ..
  19. get num
  20. else
  21. put "Next number to start at: " ..
  22. get num
  23. end if
  24.  
  25. %Delay to start printing
  26. delay (250)
  27. put " "
  28.  
  29. %Call procedure
  30. countBack
  31.  
  32. %Housekeeping
  33. put " "
  34. put " "
  35. put "------------"
  36. put " "
  37. put " "
  38.  
  39. %Increase loopcount
  40. loopcount += 1
  41.  
  42. end loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement