home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / CDRom / PET-CDW2.DMS / in.adf / rexx / Rexx-CED_Demo.ced < prev    next >
Encoding:
Text File  |  1993-07-07  |  5.7 KB  |  223 lines

  1. /*
  2. ** Rexx-CED_Demo.ced
  3. **
  4. ** $Rexx-CED_Demo.ced 1.0.1 (2.6.93)
  5. **
  6. ** This script is an example ARexx program for communicating with
  7. ** CED.
  8. **
  9. ** This script requires CygnusEd Professional v3.5 (or later) to run.
  10. **
  11. ** Copyright © 1990-1993 ASDG, Incorporated  All Rights Reserved
  12. */
  13.  
  14.  
  15. CR = '0A'X        /* Let's use a shortcut for the "cr" string... */
  16.  
  17. OPTIONS RESULTS        /* want this enabled for OKAY2 testing and other */
  18.             /* commands that return results. */
  19. ADDRESS "rexx_ced"    /* Set the default port name so that commands go to CED. */
  20.  
  21.  
  22. FirstTextLine = 6
  23.  
  24. OPEN NEW        /* Use the 'Open new' menu command to open up a new project. */
  25. EXPAND VIEW        /* Expand the new view out to full size. */
  26.  
  27.             /* Insert some blank lines. */
  28. TEXT CR
  29. TEXT CR
  30. TEXT CR
  31.  
  32.             /* Print out the title line in a fancy way. */
  33. TextLine = '               ****** ARexx <-- --> CED Demonstration ******'
  34.  
  35. DO i = LENGTH( TextLine ) TO 1 BY -1
  36.     BEG OF LINE
  37.     TEXT SUBSTR( TextLine, i, 1 )
  38. END
  39.  
  40. 'END OF LINE'
  41.  
  42. TEXT CR
  43. 'END OF FILE'
  44. TEXT CR
  45.  
  46.  
  47. TEXT 'OKAY1 Command'CR CR
  48. TEXT 'Command line = OKAY1 "The OKAY1 Command"'CR CR
  49. TEXT 'This command brings up a requester containing the message you specify'CR
  50. TEXT 'and returns when the user clicks on the "Continue" button.'CR
  51. OKAY1 "The OKAY1 Command"
  52. CALL Clear
  53.  
  54.  
  55. TEXT 'OKAY2 Command'CR CR
  56. TEXT 'Command line = OKAY2 "The OKAY2 Command"'CR CR
  57. TEXT 'This command brings up a requester containing the message you specify'CR
  58. TEXT 'with "OK" and "Cancel" buttons.  It returns when the user clicks on'CR
  59. TEXT 'one of the buttons and, if you have set results on in ARexx,  returns'CR
  60. TEXT 'a 1 or 0 depending on whether the user clicked on "OK" or "Cancel".'CR CR
  61. CALL TIME( 'r' )
  62. OKAY2 "The OKAY2 Command"
  63. Hold = RESULT        /* save the result */
  64. TEXT 'You took' TIME( 'E' ) 'seconds to respond by selecting the '
  65. IF (Hold = 1) THEN
  66.     TEXT '"OK"'
  67. ELSE
  68.     TEXT '"Cancel"'
  69. TEXT ' button'CR
  70. CALL Wait(2)
  71. CALL Clear
  72.  
  73.  
  74. TEXT 'The TEXT Command'CR CR
  75. TEXT 'The text command is used to enter a string of ASCII text into the current'CR
  76. TEXT 'file in CygnusEd.  To stop ARexx from uppercasing the text,  it should be'CR
  77. TEXT 'enclosed  in  quotes.   Non-ASCII  or  control  characters  can either be'CR
  78. TEXT 'entered as  hex  data in ARexx by putting an X after a string of hex data'CR
  79. TEXT 'or by using the "Enter ASCII" command of CygnusEd. A carriage return must'CR
  80. TEXT 'be entered at the end of each text line.'CR CR
  81. TEXT 'Example command:'CR
  82. TEXT '  TEXT "this is a line." "0a"x"'CR
  83. TEXT '        would enter...'CR
  84. TEXT '  this is a line.'CR
  85. OKAY1 'Paused...'
  86. CALL Clear
  87.  
  88.  
  89. TEXT 'The JUMPTO Command'CR CR
  90. TEXT 'Command line = "JUMPTO 10 i"'CR CR
  91. TEXT 'This command lets you jump the CygnusEd cursor to a specified line'CR
  92. TEXT 'and column number position.'CR
  93. DO i = 10 TO 30
  94.     JUMPTO 10 i
  95. END
  96. CALL Wait(2)
  97. CALL Clear
  98.  
  99.  
  100. TEXT 'The GETFILENAME Command'CR CR
  101. TEXT 'Command line = "GETFILENAME "default/file/name""'CR CR
  102. TEXT 'This command brings up the CygnusEd file requester'CR
  103. TEXT 'containing  whatever  default  file  name  you  specify.  If you have set'CR
  104. TEXT 'results on in ARexx it returns the file name the user selects,  or a NULL'CR
  105. TEXT 'string if the user selects nothing.'CR CR
  106. GETFILENAME 'default/file/name'
  107. IF (RESULT = 'RESULT') THEN
  108.     TEXT 'A NULL string was returned'CR
  109. ELSE
  110.     TEXT 'The returned string was "'RESULT'"'CR
  111. CALL Wait(2.5)
  112. CALL Clear
  113.  
  114.  
  115. TEXT 'The GETNUMBER Command'CR CR
  116. TEXT 'Command line = "GETNUMBER 100"'CR CR
  117. TEXT 'This  command  brings up the CygnusEd get_a_number requester.  The default'CR
  118. TEXT 'number  you  specify on the  commandline will be in the requester.  If you'CR
  119. TEXT 'have set results on in ARexx this  will  return  whatever  number the user'CR
  120. TEXT 'enters.  If the user cancels the requester it will return a NULL string.'CR
  121. GETNUMBER 100
  122. Hold = RESULT
  123. TEXT CR
  124. IF (Hold = '') THEN
  125.     TEXT 'A NULL was returned'CR
  126. ELSE
  127.     TEXT 'The number returned was' Hold CR
  128. CALL Wait(2)
  129. CALL Clear
  130.  
  131.  
  132. TEXT 'The ENTER ASCII Command'CR CR
  133. TEXT 'Command line = "Enter ASCII..."'CR
  134. TEXT 'CygnusEd will bring up a requester asking you to specify the'CR
  135. TEXT 'numeric value for the ASCII character you want to enter.'CR CR
  136. TEXT 'Note where the cursor is located before the command is executed'CR
  137. TEXT '(10 is the numeric value for a Carrige Return)'
  138. JUMPTO 9 1
  139. OKAY1 'Waiting...'
  140. ENTER ASCII
  141. CALL Wait(2)
  142. CALL Clear
  143.  
  144.  
  145. TEXT "Let's play with the replace command."CR CR CR CR
  146. TEXT "I'll just put in a bit of sample text.  There we are."CR
  147. TEXT "I'll just put in a bit of sample text.  There we are."CR
  148. TEXT "I'll just put in a bit of sample text.  There we are."CR
  149. CALL Wait(1)
  150. JUMPTO FirstTextLine + 2
  151. TEXT "I'm going to replace the string 'sample' with the string 'Replacement'"
  152. CALL Wait(3)
  153. Counter = 0
  154. DO i = 1 TO 3
  155.     REPLACE 'sample' 'Replacement'
  156.     CALL Wait(1)
  157. END
  158. 'END OF FILE'
  159. CALL Wait(2)
  160. CALL Clear
  161.  
  162.  
  163. String1 = 'This is '
  164. String2 = 'the end'
  165. String3 = ' of the demo.'
  166. String4 = '   Is this really '
  167. TEXT '                       '
  168. DO i = 1 TO LENGTH( String1 )
  169.     TEXT SUBSTR( String1, i, 1 )
  170. END
  171. DO i = 1 TO LENGTH( String2 )
  172.     TEXT SUBSTR( String2, i, 1 )
  173. END
  174. DO i = 1 TO LENGTH( String3 )
  175.     TEXT SUBSTR( String3, i, 1 )
  176. END
  177. CALL Wait(2)
  178. DO i = 1 TO LENGTH( String1 ) + LENGTH( String2 ) + LENGTH( String3 )
  179.     LEFT
  180. END
  181. DO i = 1 TO LENGTH( String1 )
  182.     DELETE
  183. END
  184. DO i = 1 TO LENGTH( String4 )
  185.     TEXT SUBSTR( String4, i, 1 )
  186. END
  187. DO i = 1 TO LENGTH( String2 )
  188.     RIGHT
  189. END
  190. DO i = 1 TO LENGTH( String3 )
  191.     DELETE
  192. END
  193. TEXT '?'CR
  194.  
  195. EXIT 0
  196.  
  197.  
  198. /*
  199. ** This routine clears from FirstTextLine to the end of the file -- as
  200. ** this isn't more than twenty lines.  A better version would check
  201. ** to find out when it had reached the end of the file.
  202. */
  203.  
  204. Clear:
  205.     JUMPTO FirstTextLine 1
  206.     DO i = 1 TO 20
  207.         DELETE LINE
  208.     END
  209.     RETURN 0
  210.  
  211.  
  212. /*
  213. ** This is a function to delay a specified number of seconds.
  214. */
  215.  
  216. Wait:
  217.     ARG Delay
  218.     CALL TIME( 'R' )
  219.     DO WHILE (TIME( 'E' ) < Delay)
  220.         NOP
  221.     END
  222.     RETURN 0
  223.