home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / extras / ttx / rexx / ttx_sasc / ErrorStep.ttx < prev    next >
Encoding:
Text File  |  1996-12-24  |  3.5 KB  |  189 lines

  1. /*
  2. **  $VER: ErrorStep.ttx 2.1 (17.8.93)
  3. **      By Kenneth Yarnall.  This code may be freely distributed.
  4. **
  5. **   Step to the next SAS/C (tm) error from within TurboText (tm).
  6. ** Should be bound to a key/menu entry (see TTX_SASC.dfn) and run from a
  7. ** TurboText window containing the file being compiled.
  8. **
  9. **  This takes a single argument, which should be one of the commands to
  10. ** move scmsg to a new message (next, prev, top, bottom, or blank for the
  11. ** current message).  This argument (stored in the variable 'movement') is
  12. ** Interpret'ed and sent to scmsg unadulterated.
  13. */
  14.  
  15. Options RESULTS
  16.  
  17. /* Make sure SCMsg is really running! */
  18.  
  19. if ~show('P', 'SC_SCMSG') then do
  20.     SetStatusBar "Couldn't find SCMsg -- aborting"
  21.     exit 10
  22. end
  23.  
  24. /*
  25. ** Get the current TurboText port and store it
  26. */
  27.  
  28. primo.port = Address()
  29. SetClip('primo_port', primo.port)
  30.  
  31. /*
  32. ** Get the command line argument
  33. */
  34.  
  35. parse arg movement
  36.  
  37. /*
  38. ** Get basic info from scmsg
  39. */
  40.  
  41. Address 'SC_SCMSG'
  42.  
  43. /*
  44. **  Move depending on the argument given, and analyse the new error.
  45. ** Interpret is my favorite Rexx command...
  46. */
  47.  
  48. Interpret movement
  49.  
  50. /*
  51. **  Get the name of the main file from scmsg.  If there is no file name,
  52. ** there are no errors.
  53. */
  54.  
  55. 'file'
  56. main.path = RESULT
  57.  
  58. if main.path = "" then do      /* No messages in the Browser */
  59.     Address VALUE primo.port
  60.     SetStatusBar "No SAS/C errors"
  61.     exit 0
  62. end
  63.  
  64. /*
  65. **  Now check for an alternate file
  66. */
  67.  
  68. 'altfile'
  69. alt.path = RESULT
  70.  
  71. /*
  72. **  Retrieve the number and text of the message from scmsg.
  73. */
  74.  
  75. 'number'
  76. err.num = RESULT
  77.  
  78. 'text'
  79. err.text = RESULT
  80.  
  81. /*
  82. **  Process the main file.
  83. */
  84.  
  85. Call MainFile
  86.  
  87. /*
  88. **  Process the alternate file, if any.
  89. **
  90. **  The reason I put these two sections into "subroutines" is so that the
  91. ** order in which they are called can easily be switched.
  92. */
  93.  
  94. if alt.path ~= "" then
  95.     Call AltFile
  96.  
  97. /*  All there is to it. */
  98.  
  99. exit 0
  100.  
  101. /*-------------------------------------------------------------------*/
  102.  
  103. MainFile:
  104.  
  105. Address SC_SCMSG
  106. 'line'
  107. main.line = RESULT
  108.  
  109. /*  Now find the filename portion of main.path */
  110.  
  111. main.name = 'Rexx:TTX_SASC/GetFilePart'(main.path)
  112.  
  113. /*
  114. **  Find the window containing the main file.
  115. */
  116.  
  117. Call FindFilePort main.name,main.path
  118. main.port = RESULT
  119.  
  120. if main.port = ""
  121.     then Return
  122.  
  123. Address VALUE main.port
  124. Window2Front
  125. ActivateWindow
  126. Move FOLDS main.line
  127. SetStatusBar err.num||': '||err.text
  128.  
  129. Return
  130.  
  131. /*-------------------------------------------------------------------*/
  132.  
  133. AltFile:
  134.  
  135. Address SC_SCMSG
  136. 'altline'
  137. alt.line = RESULT
  138.  
  139. /*  Now find the filename portion of alt.path */
  140.  
  141. alt.name= 'Rexx:TTX_SASC/GetFilePart'(alt.path)
  142.  
  143. /*
  144. **  Find the window containing the alternate file.
  145. */
  146.  
  147. Call FindFilePort alt.name,alt.path
  148. alt.port = RESULT
  149.  
  150. if alt.port = ""
  151.     then Return
  152.  
  153. Address VALUE alt.port
  154. Window2Front
  155. ActivateWindow
  156. Move FOLDS alt.line
  157. SetStatusBar err.num||': '||err.text
  158.  
  159. Return
  160.  
  161. /*-------------------------------------------------------------------*/
  162.  
  163.  
  164. /*
  165. **  FindFilePort -- Finds the TurboText port corresponding to a file, or
  166. ** tries to open the file if it is not in memory.  The TTX address was
  167. ** stored in a clip earlier so that we could get at it again here.
  168. */
  169.  
  170. FindFilePort: PROCEDURE
  171.  
  172. Parse arg file,path
  173.  
  174. Address TurboText GetPort file
  175.  
  176. if RESULT = "RESULT" then do
  177.     Address VALUE GetClip('primo_port')
  178.     promptstr = '"Load ' || file || '?"'
  179.     RequestBool '"TTX <=> SAS/C"' promptstr
  180.     if RESULT = "YES" then do
  181.         OpenDoc NAME path
  182.         Return RESULT
  183.     end
  184.     else
  185.         Return ""
  186. end
  187. else
  188.     Return RESULT
  189.