home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / DSY-LA11.LHA / arexx / LearnArexx.dsrx < prev   
Encoding:
Text File  |  1996-04-07  |  10.3 KB  |  512 lines

  1.  
  2. /* This is a comment which must begin a Arexx script at ALL times! */
  3.  
  4. /* This is a "Nested" Comment /* (A comment within another comment) */ */
  5.  
  6. call time('R')
  7.  
  8. /* Start the Elapsed time counter.. This will come in handy l8er.. */
  9.  
  10.  Address command
  11.  
  12. /* Set the output address of commands to the CON: (Shell) */
  13.  
  14.  'cls'
  15.  'echo " .------------------------------------------------------------."'
  16.  'echo " | This is an example Arexx script by Fusion/LNS^dSY in 1996. |"'
  17.  'echo " `------------------------------------------------------------''"'
  18.  'echo " Type your name or Alias Backwards and press Enter.."'
  19.  
  20. /* Send the commands above to the "command" address (Shell) */
  21.  
  22.  Address
  23.  
  24. /* Return to the previous address (Default REXX port Address) */
  25.  
  26.  say ''
  27.  
  28. /* Normal way to make a linefeed.. */
  29.  
  30.  pull Name
  31.  
  32.  say ''
  33.  
  34. /* Wait for input and store the input in the variable "Name" */
  35.  
  36.  say ' So your name or Alias is 'Reverse(Name)'!:.'
  37.  
  38. /* Reverse the name entered backwards to get it right and print it */
  39.  
  40.  say ''
  41.  
  42. /* Simple way of getting a linefeed.. */
  43.  
  44.  Address command 'waitreturn'
  45.  
  46. /* Use C: command "Waitreturn" from CLI */
  47.  
  48.  Address
  49.  
  50. /* Restore the Address to REXX port */
  51.  
  52.  Signal on break_E
  53.  
  54. /* Jump to Label Clause "BREAK_E" when you press CTRL-E */
  55.  
  56.  bc = 0
  57.  
  58. /* Assign value 0 to the variable bc */
  59.  
  60.  do forever
  61.  
  62. /* Start a DO loop and execute all between DO and END unlimited times */
  63.  
  64.  say value(bc)
  65.  
  66. /* Print the current value of the variable "bc" */
  67.  
  68.  bc = bc+1
  69.  
  70. /* give variable "bc" a new value (its original value +1) */
  71.  
  72.  say ' Press CTRL-E Now to stop this Looping!:.'
  73.  
  74. /* Print this string in the shell window */
  75.  
  76.  end
  77.  
  78. /* End of the DO loop (MUST ALWAYS be present when DO is used!) */
  79.  
  80. BREAK_E:
  81.  
  82. /* This is a "Label Clause" in which it will jump to on a CTRL+E break */
  83.  
  84.  say ''
  85.  say " Good, It was repeated "bc" times before you made the brake!:."
  86.  
  87. /* Print this string with bc (amount of times the break message printed) */
  88.  
  89.  say ''
  90.  say ' Enter your current Age in years please..'
  91.  
  92.  pull Age
  93.  
  94.  say ''
  95.  
  96. /* You know now what this above means right?! */
  97.  
  98.  if Age > 15 then call AGEMAX
  99.  
  100. /* If the age in years is above 15 call Label Clause "AGEMAX" */
  101.  
  102.  else
  103.  
  104. /* If the Age was below 15 then continue here.. */
  105.  
  106.  call AGEMIN
  107.  
  108. /* Call Label Clause "AGEMIN" */
  109.  
  110. AGEMAX:
  111.  
  112. /* "AGEMAX" Label clause */
  113.  
  114.  say ' Allright, you are old enough.. '
  115.  
  116.  call CONTINUE
  117.  
  118. /* Print string and jump to Label Clause "CONTINUE" */
  119.  
  120. AGEMIN:
  121.  
  122.  say ' Humm, You are still a kid!:. ;)'
  123.  
  124. CONTINUE:
  125.  
  126.  say ''
  127.  say ' Enter some numbers with a space between each of them..'
  128.  say ''
  129.  
  130.  pull numbs
  131.  
  132.  say ''
  133.  say " Allright, lets add them.. "Space(numbs,'1','+')" is?:."
  134.  say ''
  135.  
  136. /* Print strings, And fill spaces in numbers given with +'es */
  137.  
  138.  pull amo
  139.  
  140.  call random(,, time(s))
  141.  tms = random(1,9)
  142.  
  143. /* Assign a random number value between 1 and 9 to variable "tms" */
  144.  
  145.  say ''
  146.  say " The numbers added times "tms" is.. "tms*amo"!:."
  147.  
  148. /* print result of numbers and result of times the random number. */
  149.  
  150.  say ''
  151.  say ' Now enter a sentence of a couple of words..'
  152.  say ''
  153.  
  154.  pull sent
  155.  
  156. /* Print strings and get input to variable "sent" */
  157.  
  158.  wrs = words(sent)
  159.  
  160. /* Get amount of words variable "sent" contains to variable "wrs" */
  161.  
  162.  chr = length(space(sent,0))
  163.  
  164. /* assign value on lenght of input "sent" without Spaces to the variable */
  165. /* "chr" "Space(sent,0)" strips ALL spaces and length() gives # chars..  */
  166.  
  167.  say ''
  168.  say " You wrote "chr" characters (without spaces) in the sentence."
  169.  say " And you totally used "wrs" Word(s) in it.."
  170.  say ''
  171.  
  172. /* Send string with value of variable "chr" */
  173.  
  174.  options prompt " Continue this program? (Y/n): "
  175.  
  176. /* Print a prompt with the string between the "" characters.. */
  177.  
  178.  pull well
  179.  
  180. /* Get input from user and put it in variable "well" */
  181.  
  182.  if well = Y then call GREEN
  183.  
  184. /* if variable well was Y or y then call label clause "GREEN"  */
  185. /* if variable well is anything else then Y or y continue here */
  186.  
  187.  say ''
  188.  say ' Thanx for using LearnArexx v1.1 (c) by Fusion/lNS^dSY 1996..'
  189.  say ''
  190.  
  191.  exit
  192.  
  193. GREEN:
  194.  
  195.  say ''
  196.  say " Ok, You have been in the program for "time('E')" seconds now."
  197.  say ''
  198.  
  199. /* Print linefeeds and string with elapsed time total.. ( time('E') ) */
  200.  
  201.  options
  202.  
  203. /* Reset Options settings to their defaults.. */
  204.  
  205.  say ' Allright.. Enter to continue..'
  206.  
  207.  pull
  208.  
  209.  say ''
  210.  
  211. /* Wait for a keypress.. */
  212.  
  213.  address command 'cls'
  214.  
  215. /* Use C: Command CLS in CLI on the Shell windows address.. */
  216.  
  217.  echo "H/\"
  218.  echo "H  "
  219.  echo "H/\"
  220.  echo "H  "
  221.  echo "H/\"
  222.  echo "H  "
  223.  echo "H/\"
  224.  echo "H  "
  225.  echo "H/\"
  226.  echo "H  "
  227.  echo "H/\"
  228.  echo "H  "
  229.  echo "H/\"
  230.  echo "H  "
  231.  echo "H/\"
  232.  echo "H  "
  233.  echo "H/\"
  234.  echo "H  "
  235.  echo "H/\"
  236.  echo "H  "
  237.  echo "0H/\"
  238.  echo "0H  "
  239.  echo "1H/\"
  240.  echo "1H  "
  241.  echo "2H/\"
  242.  echo "2H  "
  243.  echo "3H/\"
  244.  echo "3H  "
  245.  echo "4H/\"
  246.  echo "4H  "
  247.  echo "5H/\"
  248.  echo "5H  "
  249.  echo "6H/\"
  250.  echo "6H  "
  251.  echo "7H/\>"
  252.  echo "7H/\÷>"
  253.  echo "7H/\-÷>"
  254.  echo "7H/\--÷>"
  255.  echo "7H/\---÷>"
  256.  echo "7H/\----÷>"
  257.  echo "7H/\-----÷>"
  258.  echo "7H/\------÷>"
  259.  echo "7H/\------÷> F"
  260.  echo "7H/\------÷> Fu"
  261.  echo "7H/\------÷> Fus"
  262.  echo "7H/\------÷> Fusi"
  263.  echo "7H/\------÷> Fusio"
  264.  echo "7H/\------÷> Fusion"
  265.  echo "7H/\------÷> Fusion."
  266.  echo "7H/\------÷> Fusion.."
  267.  
  268. /* An ASCII animation by Me.. Using Arexx ECHO command in CLI.. */
  269.  
  270.  say ''
  271.  
  272. /* Normal linefeed.. */
  273.  
  274.  say ' Hiya [ 'centre(reverse(name),50)' ]'
  275.  
  276. /* Print [ Hiya "Name" ] reversed and centered in a 50 character space! */
  277.  
  278.  say ''
  279.  say ' Enter A word, How many times on 1 line it should be printed,'
  280.  say ' And how many lines it should be printed on. (ex. cool 3 2): '
  281.  say ''
  282.  
  283.  pull cpa cpb cpc
  284.  
  285. /* Print strings and pull three values for three variables.. */
  286.  
  287.  say ''
  288.  
  289.  do ""cpc""
  290.  
  291.  say ''copies(cpa,''cpb'')''
  292.  
  293.  end
  294.  
  295.  say ''
  296.  
  297. /* A loop that prints word in variable "cpa" "cpb" times on each line */
  298. /* And over value of variable "cpc" lines.. */
  299.  
  300.  if ~exists('SYS:S/User-Startup') then call NO
  301.  
  302. /* If U dont have User-Startup in SYS:S/ directory call NO label clause */
  303.  
  304.  call YES
  305.  
  306. /* Call (jump) to label clause named "YES:" */
  307.  
  308. NO:
  309.  
  310.  say 'What!? You haven''t got any User-Startup file in SYS:S/ dir!:.'
  311.  say ''
  312.  say 'Enter to continue..'
  313.  say ''
  314.  
  315.  pull
  316.  
  317.  call MOVE
  318.  
  319. YES:
  320.  
  321.  say ' The file SYS:S/User-Startup is present in your system..'
  322.  say ''
  323.  say ' Enter to continue..'
  324.  
  325.  pull
  326.  
  327. MOVE:
  328.  
  329.  say ' Enter 3 numbers on one line seperated by a space each..'
  330.  say ''
  331.  
  332.  pull nu1 nu2 nu3
  333.  
  334.  say ''
  335.  say ' Now lets take the highest number of them and devide it by 3..'
  336.  say ''
  337.  
  338. /* All of this you sure as heckfire know by now.. */
  339.  
  340.  ops = Max(nu1,nu2,nu3)
  341.  
  342. /* Assign value of the highest number of the 3 entered 2 variable "ops" */
  343.  
  344.  numeric digits 6
  345.  
  346. /* All numeric calculations should have 6 digits precision! */
  347.  
  348.  got = ops / 3
  349.  
  350. /* Devide variable ops with 3 and assign the new value 2 variable "got" */
  351.  
  352.  say ' Well, 'ops' devided by 3 is.. 'got'!:.'
  353.  say ' That is with 6 digits of precision..'
  354.  say ''
  355.  
  356. /* Give the string with higest number and the devided by 3 result */
  357.  
  358.  options prompt " Continue this program? (Y/n): "
  359.  
  360.  pull well
  361.  
  362.  if well = Y then call GREEN2
  363.  
  364.  say ''
  365.  
  366.  exit
  367.  
  368. /* This time I overwrite the old value of variable well to a new one! */
  369.  
  370. GREEN2:
  371.  
  372. options
  373.  
  374. /* Reset the options argument.. */
  375.  
  376.  address command 'cls'
  377.  
  378.  say ''
  379.  say ' And now for some info about YOUR Arexx interpreters enviorment!'
  380.  say ''
  381.  
  382. /* Basic stuff you REALLY should know about at this moment.. */
  383.  
  384.  parse version ver
  385.  
  386. /* Get the Interpreter Enviorment Version string into variable "ver" */
  387.  
  388.  say ' 'ver''
  389.  say ''
  390.  say ' Answers: Arexx Version?, CPU?, FPU?, VIDEO?, FREQUENCY?'
  391.  say ''
  392.  say ' Enter to continue...'
  393.  
  394.  pull
  395.  
  396. /* Nice output on system information.. */
  397.  
  398.  call open('Text','RAM:Story.txt','W')
  399.  
  400. /* Create new file in RAM: called Story.txt and be ready to write data */
  401. /* Into that file called "Text" with the writeln commands later on.. */
  402.  
  403.  say ' Enter a nice little story over three lines (Return after each)..'
  404.  say ''
  405.  
  406.  pull lin1
  407.  pull lin2
  408.  pull lin3
  409.  
  410. /* Print strings and get the "3 line story" into three variables.. */
  411.  
  412.  call writeln('Text',''lin1'')
  413.  call writeln('Text',''lin2'')
  414.  call writeln('Text',''lin3'')
  415.  
  416. /* write the three "story" lines into the opened (Text) file in RAM: */
  417.  
  418.  call close('Text')
  419.  
  420. /* close the opened file RAM:Story.txt, we have finished using it.. */
  421.  
  422.  address command
  423.  
  424.  'cls'
  425.  'echo ""'
  426.  'type RAM:Story.txt'
  427.  
  428. /* Make Shell window HOST and execute commands in that host address.. */
  429.  
  430.  address
  431.  
  432. /* Return host to REXX port.. The default port for Arexx scripts.. */
  433.  
  434.  say ''
  435.  say ' Well, Thats your story.. You can find the story in a file called'
  436.  say ' Story.txt in your RAM: disk.. for later use maybe..'
  437.  say ''
  438.  say ' Enter to go on..'
  439.  
  440.  pull
  441.  
  442. /* Some strings and a "Arexx" simulated waitreturn command.. */
  443.  
  444.  options prompt ' Do you want to delete the story textfile in RAM? (y/N): '
  445.  
  446.  pull del
  447.  
  448.  if del = Y then call DELETE
  449.  
  450.  say ''
  451.  say ' Allright, The text was not deleted and is present in device RAM!'
  452.  say ''
  453.  say ' Enter to move it all on further..'
  454.  
  455.  options
  456.  
  457.  pull
  458.  
  459. /* This you should already know if you have read everything carefully.. */
  460.  
  461. END:
  462.  
  463.  address command 'cls'
  464.  
  465.  say ''
  466.  say ' Well, You have now on 'Date()' reached the end of Fusions'
  467.  say ' LearnArexx v1.1, hope you liked it.. Edit the source with'
  468.  say ' Your favorite Editor and have a look on how it was made!:.'
  469.  say ' This source is (c) by Fusion 1996 and if you are going to'
  470.  say ' cut out and use anything in this I whould appriciate it if'
  471.  say ' you mentioned me in the docs/sources or whatever.. Or you'
  472.  say ' can mention me if you learned much here that helped you'
  473.  say ' with whatever you code in the docs or in the Program/Game.'
  474.  
  475.  say ''
  476.  
  477. /* A little END text.. And an important one too.. */
  478.  
  479.  exit
  480.  
  481. /* Exit (Quit) The program and return nicely to the system.. */
  482.  
  483. DELETE:
  484.  
  485.  address command 'delete >NIL: RAM:Story.txt'
  486.  
  487. /* Execute line between '' characters in CLI.. */
  488.  
  489.  say ''
  490.  say ' Allright, The story file has been succesfully deleted..'
  491.  say ''
  492.  say ' Enter to move on..'
  493.  
  494. /* Print a couple of strings.. */
  495.  
  496.  options
  497.  
  498. /* Return options value to defaults.. */
  499.  
  500.  pull
  501.  
  502. /* Wait for a input.. */
  503.  
  504.  call END
  505.  
  506. /* Call (Jump To) Label Clause named "END" */
  507.  
  508.  exit
  509.  
  510. /* Exit the program and give full control back to shell.. */
  511.  
  512.