home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / comal3-2.dms / in.adf / RexxScripts / SaveModule.Comal < prev    next >
Encoding:
Text File  |  1993-04-10  |  1.7 KB  |  68 lines

  1. /****************************************************************/
  2. /*                                                              */
  3. /* Cut off local module and save as external module             */
  4. /*                                                              */
  5. /*    Place the cursor somewhere inside the internal module     */
  6. /*    you want to save as an external module. The module will   */
  7. /*    be saved in the file Modules/modulename.mod and if        */
  8. /*    success it will be cut off the program text.              */
  9. /*                                                              */
  10. /****************************************************************/
  11.  
  12. OPTIONS RESULTS
  13. 'COMALPATH'
  14. ComalDir = RESULT
  15.  
  16. DO FOREVER
  17.   OPTIONS RESULTS
  18.   'GETTEXT'
  19.   Line = RESULT
  20.   IF ( SUBSTR(Line,1,6)=='MODULE' ) THEN BREAK
  21.   OPTIONS
  22.   'CURSOR UP'
  23.   IF RC>0 THEN BREAK
  24. END
  25.  
  26. IF ( SUBSTR(Line,1,6)=='MODULE' )
  27.   THEN DO
  28.     File = ComalDir || 'Modules/' || SUBSTR(Line,8,LENGTH(Line)-7) || '.mod'
  29.     num = 1
  30.     address 'Comal.CodeMan'
  31.     OPTIONS RESULTS
  32.     'OPEN'
  33.     ID = RESULT
  34.     DO FOREVER
  35.       OPTIONS
  36.       MAKECODE 'ID ' ID Line
  37.       INSERT 'ID ' ID
  38.       'LINE ID ' ID 1
  39.       num = num + 1
  40.       IF ( SUBSTR(Line,1,9)=='ENDMODULE' ) THEN BREAK
  41.       address
  42.       'CURSOR DOWN'
  43.       IF RC>0 THEN BREAK
  44.       OPTIONS RESULTS
  45.       'GETTEXT'
  46.       Line = RESULT
  47.       address
  48.     END
  49.     IF ( SUBSTR(Line,1,9)=='ENDMODULE' )
  50.       THEN DO
  51.         'SAVE ID ' ID FILENAME File
  52.         'CLOSE' 'ID ' ID
  53.         address
  54.         DO num
  55.           'DELLINE'
  56.           'CURSOR UP'
  57.         END
  58.       END
  59.       ELSE DO
  60.         address
  61.         WRITESTATUS 'ENDMODULE missing'
  62.       END
  63.   END
  64.   ELSE DO
  65.     OPTIONS
  66.     WRITESTATUS 'Not inside MODULE'
  67.   END
  68.