home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / amiga / 675 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  5.6 KB

  1. Path: sparky!uunet!convex!darwin.sura.net!jvnc.net!rutgers!ukma!cs.widener.edu!gvls1!tredysvr!cnmss!efb
  2. From: efb@cnmss.tredydev.unisys.com (Edward Bacon)
  3. Newsgroups: alt.sources.amiga
  4. Subject: SAS/C Browser and TurboText script
  5. Message-ID: <1992Nov16.194447.661@cnmss.tredydev.unisys.com>
  6. Date: 16 Nov 92 19:44:47 GMT
  7. Distribution: alt.sources.amiga
  8. Organization: Unisys Corporation, Tredyffrin
  9. Lines: 267
  10.  
  11.  
  12. Here is an AREXX script I use to go to lines with errors from the
  13. SAS/C message browser(scmsg).  Please read the comments for more
  14. information.
  15. Regards,
  16. Ed.
  17.  
  18. /*
  19. **  $VER: FileSC.ttx 1.0 (30 Oct 1992)
  20. **      By E. F, Bacon.  This code may be freely distributed.
  21. **
  22. **    Used by SCmsg (SAS/C Message Browser) to open file and goto the line
  23. **    of the current error when you double click or type return on an error
  24. **  message.  Set the GOTOFILE option to this file and set the PORTNAME
  25. **  to AREXX.
  26. **
  27. **    My SCMSG environment is:
  28. **
  29. **        LEFT 0
  30. **        TOP 329
  31. **        WIDTH 640
  32. **        HEIGHT 71
  33. **        NOHIDDEN
  34. **        NOREXXONLY
  35. **        AUTOEDIT
  36. **        PORTNAME AREXX
  37. **        EDITCOMMAND turbotext:TTX "%f"
  38. **        GOTOFILE REXX:FileSc.TTX
  39. **        NOGOTOLINE
  40. **
  41. **    Note that I have not had much success when PORTNAME is TURBOTEXT,
  42. **    so I send the commands to AREXX which just executes this script.
  43. **  [I guess this filename should really be FileSC.rexx ?]
  44. **
  45. **  I do not know why scmsg does not start the editor, see Locate_TURBOTEXT
  46. **  below.
  47. **
  48. **  BUGS:
  49. **  If the error is in a file that has the same name as an active document,
  50. **  then this code may go to the line of the wrong document.  See the
  51. **  FindFilePort procedure below.
  52. **
  53. **    Some ideas for this were borrowed from the TTX scripts that came
  54. **  with SAS/C v6.0 by Kenneth Yarnall.
  55. */
  56.  
  57. OPTIONS RESULTS
  58.  
  59. /*
  60.  * You need to have TTX running first.  I do not know why scmsg does
  61.  * not start the editor. So if TTX is not running this starts it.
  62.  */
  63. CALL Locate_TURBOTEXT
  64.  
  65. IF RESULT ~= 1 THEN EXIT
  66.  
  67.  
  68. /*
  69.  * Get basic info from scmsg
  70.  */
  71.  
  72. ADDRESS 'SC_SCMSG'
  73.  
  74. /*
  75.  *  Get the name of the main file from scmsg.  If there is no file name,
  76.  * there are no errors.
  77.  */
  78.  
  79. 'file'
  80. main.path = RESULT
  81.  
  82. IF main.path = ""  THEN DO
  83.     /* No messages in the Browser */
  84.     EXIT
  85. END
  86.  
  87. /*
  88.  *  Now check for an alternate file
  89.  */
  90.  
  91. 'altfile'
  92. alt.path = RESULT
  93.  
  94. /*
  95.  *  Retrieve the number and text of the message from scmsg.
  96.  */
  97.  
  98. 'number'
  99. err.num = RESULT
  100.  
  101. 'text'
  102. err.text = RESULT
  103.  
  104. /*
  105.  *  Process the main file.
  106.  */
  107.  
  108. CALL MainFile
  109.  
  110.  
  111. /* ******************   no alt file processing   ***********
  112. IF alt.path ~= "" THEN
  113.     CALL AltFile
  114. *************************** */
  115.  
  116. /*  All there is to it. */
  117.  
  118. EXIT 0
  119.  
  120.  
  121.  
  122. /*-------------------------------------------------------------------*/
  123.  
  124. MainFile:
  125.  
  126. ADDRESS SC_SCMSG
  127. 'line'
  128. main.line = RESULT
  129.  
  130. /*  Now find the filename portion of main.path */
  131.  
  132. CALL FindFileName main.path
  133. main.name = RESULT
  134.  
  135. /*
  136.  *  Find the window containing the main file.
  137.  */
  138.  
  139. CALL FindFilePort main.name,main.path
  140. main.port = RESULT
  141.  
  142. IF main.port = "" THEN RETURN
  143.  
  144. /* bring the window to the front and goto to the line with the error */
  145. ADDRESS VALUE main.port
  146. Window2Front
  147. IconifyWindow OFF
  148. ActivateWindow
  149. Move FOLDS main.line
  150. SetStatusBar err.num||': '||err.text
  151.  
  152. RETURN
  153.  
  154.  
  155.  
  156. /*-------------------------------------------------------------------*/
  157.  
  158. AltFile:
  159.  
  160. ADDRESS SC_SCMSG
  161. 'altline'
  162. alt.line = RESULT
  163.  
  164. /*  Now find the filename portion of alt.path */
  165.  
  166. CALL FindFileName alt.path
  167. alt.name = RESULT
  168.  
  169. /*
  170. **  Find the window containing the alternate file.
  171. */
  172.  
  173. CALL FindFilePort alt.name,alt.path
  174. alt.port = RESULT
  175.  
  176. IF alt.port = "" THEN RETURN
  177.  
  178. /* bring the window to the front and goto to the line with the error */
  179. ADDRESS VALUE alt.port
  180. Window2Front
  181. IconifyWindow OFF
  182. ActivateWindow
  183. Move FOLDS alt.line
  184. SetStatusBar err.num||': '||err.text
  185.  
  186. RETURN
  187.  
  188.  
  189.  
  190. /*-------------------------------------------------------------------*/
  191.  
  192. /*
  193. ** FindFileName -- Extracts the filename part of a path specification.
  194. */
  195.  
  196. FindFileName: PROCEDURE
  197. parse arg path
  198.  
  199. dirend = LastPos('/', path)
  200. IF dirend = 0 THEN
  201.     dirend = Pos(':', path)
  202. IF dirend ~= 0 THEN
  203.     name = SubStr(path, dirend+1)
  204. ELSE name = path
  205.  
  206. RETURN name
  207.  
  208.  
  209.  
  210. /*-------------------------------------------------------------------*/
  211.  
  212. /*
  213.  * FindFilePort -- Finds the TurboText port corresponding to a file, or
  214.  * tries to open the file if it is not in memory.
  215.  *
  216.  * Note that if this is the second file with same name as an active
  217.  * document, this code returns the port of the first document.
  218.  */
  219.  
  220. FindFilePort: PROCEDURE
  221. parse arg file,path
  222.  
  223. /*
  224.  * Search current documents for file
  225.  */
  226. ADDRESS TURBOTEXT
  227. GetDocuments
  228. docs = RESULT
  229. DO WHILE docs ~= ''
  230.     PARSE VAR docs '"' docname '"' port docs
  231.     IF file == docname THEN DO
  232.             RETURN port
  233.     END
  234. END
  235.  
  236. /* there was no port open a new one */
  237. ADDRESS TURBOTEXT
  238. OpenDoc NAME path
  239. Return RESULT
  240.  
  241.  
  242. /*-------------------------------------------------------------------*/
  243.  
  244. /*
  245. ** Looks for TURBOTEXT port, starts ttx if not found
  246. */
  247.  
  248. Locate_TURBOTEXT:
  249.  
  250. /* if the port is there, just return (afirmative) */
  251. IF POS('TURBOTEXT' , SHOW('Ports')) ~= 0 THEN RETURN 1
  252.  
  253. Max_Seconds_To_Load = 60
  254. Flag = 0
  255. LibName = 'rexxsupport.library'
  256.  
  257. /* make sure we have needed libraries */
  258. IF POS(LibName , SHOW('Libraries')) = 0 THEN ADDLIB(LibName , 0 , -30 , 0)
  259. IF POS(LibName , SHOW('Libraries')) = 0 THEN RETURN 0
  260.  
  261. /* is there a volume TURBOTEXT: ? */
  262. IF STATEF('TURBOTEXT:') = "" THEN RETURN 0
  263.  
  264. /* start up TTX and wait for the port */
  265. TIME('R')
  266. DO WHILE (Time('E') < Max_Seconds_To_Load) & (POS('TURBOTEXT' , SHOW('Ports')) = 0)
  267.     IF Flag = 0 THEN DO
  268.         /* Set whatever command line arguments you want. */
  269.         ADDRESS COMMAND 'run < nil: > nil: TURBOTEXT:TTX BG NW'
  270.         Flag = 1
  271.     END
  272.     ADDRESS COMMAND 'WAIT 1'
  273. END
  274.  
  275. /* final check for the port */
  276. IF POS('TURBOTEXT' , SHOW('Ports')) = 0 THEN RETURN 0
  277. ELSE RETURN 1
  278.