home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / basmify_v1.1 / nexterror.ced < prev   
Text File  |  1977-12-31  |  10KB  |  381 lines

  1. /* Show errors produced by Assemble.ced.
  2. **
  3. ** This ARexx script shows the next of the errors in the
  4. ** error list of BAsm, after a Assemble.ced run.
  5. ** CygnusEd is used to display the errors.
  6. **
  7. ** Written and copyright 1995-1996 by Ulrich Flegel.
  8. ** All rights are reserved to the author Ulrich Flegel.
  9. **
  10. ** Publication and distribution only allowed by explicitly written permission from the author.
  11. ** This software may be distribute on the Aminet CD-ROMs.
  12. **
  13. ** system requirements:
  14. **    Assemble.ced        (V1.1    or higher)
  15. **    CygnusEd        (V3.5    or higher)
  16. **    BAsm            (V1.123  or higher)
  17. **    SetEnv            (AmigaOS release)
  18. **    rx            (ARexx   release)
  19. **
  20. ** current version of this script:
  21. **
  22. ** $VER: NextError.ced V1.1 (06-Jan-96)
  23. **
  24. ** usage:
  25. ** call as ARexx Macro from CygnusEd as: "NextError.ced [LOCALE «Language»]  [OPT «BAsmOptions»]"
  26. ** Example «Language»: deutsch
  27. ** Example «BAsmOptions»: -O+ -OW+
  28. ** 
  29. */
  30.  
  31. /*============================================================================*/
  32.  
  33. OPTIONS RESULTS                    /* enable return codes     */
  34.  
  35. /*============================================================================*/
  36.  
  37. /* parameters used to control this program */
  38.  
  39. /* NextError.ced [PORT «Port_CygnusEd»] [LOCALE «Language»] [OPT «BAsmOptions»] */
  40.  
  41. PARSE ARG CommandLine
  42.  
  43. /*============================================================================*/
  44.  
  45. /* adapt the following variables to your system environment: */
  46.  
  47. Assemble        = 'BAsmify:Assemble.ced'    /* here substitute the complete path/name of the Assemble.ced script */
  48. MaxViews    = 20                /* here substitue the maximum number of views CygnusEd is able to open */
  49.  
  50. /*============================================================================*/
  51.  
  52. BAsmError_Max        = 200
  53. BAsmError_OK        = 0
  54. BAsmError_False        = 20
  55. BAsmError_OpenError    = 1
  56. BAsmError_SourceError    = 2
  57. BAsmError_ReadError    = 3
  58. BAsmError_UnknownOption    = 4
  59. BAsmError_MemoryError    = 5
  60. BAsmError_NoSourceFile    = 6
  61. BAsmError_NoNextError    = 7
  62. BAsmError_NoErrorList    = 8
  63. BAsmError_NoNextWarning    = 9
  64. BAsmError_NoWarningList    = 10
  65.  
  66. /*============================================================================*/
  67.  
  68. /*
  69. ** Intialize parameter variables and parse commandline
  70. */
  71.  
  72. Port_CygnusEd=''
  73. Language=''
  74. BAsmOptions=''
  75.  
  76. DO FOREVER
  77.     PARSE VAR CommandLine Parameter CommandLine
  78.     IF Parameter = ''       THEN LEAVE
  79.     PARSE VAR CommandLine Argument CommandLine
  80.     IF Argument  = ''       THEN LEAVE
  81.  
  82.     SELECT
  83.     WHEN Parameter = 'PORT'   THEN Port_CygnusEd=Argument
  84.     WHEN Parameter = 'LOCALE' THEN Language=Argument
  85.     WHEN Parameter = 'OPT'    THEN BAsmOptions=Argument||CommandLine
  86.     END
  87. END                      
  88.  
  89. /*============================================================================*/
  90.  
  91. /* Only Assemble.ced may supply the parameter Port_CygnusEd above !! */
  92. /* If parameter correct, it is assumed, that the first error is not to be skipped */
  93.  
  94. IF (LEFT(Port_CygnusEd, 8) = 'rexx_ced') THEN
  95.     InvokedByAssembleScript = TRUE
  96. ELSE
  97.     InvokedByAssembleScript = FALSE
  98.  
  99. /*============================================================================*/
  100.  
  101. /* ARexx ports used */
  102.  
  103. Port_BAsm='rexx_BASM'
  104.  
  105. IF (Port_CygnusEd='') THEN Port_CygnusEd=ADDRESS()
  106. IF (LEFT(Port_CygnusEd, 8) ~= 'rexx_ced') THEN Port_CygnusEd='rexx_ced'
  107.  
  108. /*============================================================================*/
  109.  
  110. ScriptErrorLevel = 6
  111.  
  112. SIGNAL ON SYNTAX                /* ensure clean exit       */
  113.  
  114. IF ~ SHOW('P', Port_CygnusEd) THEN        /* is CygnusEd AREXX port available ? */
  115. DO
  116.     Say 'This script may only called by CygnusEd!'
  117. END
  118. ELSE
  119. DO
  120.  
  121. OPTIONS FAILAT ScriptErrorLevel            /* ignore warnings         */
  122.  
  123. /*============================================================================*/
  124.  
  125. /*
  126. ** Non localized strings used
  127. */
  128.  
  129.  
  130. STRING_ThisScript='NextError.ced'
  131.  
  132. /*
  133. ** Localization of strings used
  134. */
  135.  
  136. IF ( Language = '' ) THEN        /* ask CED for current language if none submitted */
  137. DO
  138.     ADDRESS VALUE Port_CygnusEd
  139.     /*'QUERY CAT'*/            /* !!! here find out which language CED uses currently */
  140.     /*Language=RESULT*/
  141. END
  142.  
  143. SELECT
  144. WHEN Language='deutsch' THEN
  145.     DO
  146.     STRING_Positive='OK'
  147.     STRING_Negative='Abbrechen'
  148.     STRING_Dismiss='Aufgeben'
  149.     STRING_BAsmFailure_Title='BAsm Fehler-Report'
  150.     ERROR_NoBAsm='Der Source wurde noch nicht assembliert! Soll dies JETZT geschehen?'
  151.     ERROR_BASM_UnknownErrorCode='Ein unbekannter Fehler ist aufgetreten!'
  152.     ERROR_BASM_NoNextErrorWarning='Keine weiteren Fehler bzw. Warnungen vorhanden!'
  153.     ERROR_BASM_NoErrorWarningList='Keine Fehlerliste bzw. Warnungsliste vorhanden!'
  154.     ERROR_BASM_InLine='in Zeile'
  155.     ERROR_BASM_Of='von'
  156.     END
  157. /*
  158. WHEN Language='XXX' THEN
  159.     DO
  160.     STRING_Positive='XXX'
  161.     STRING_Negative='XXX'
  162.     STRING_Dismiss='XXX'
  163.     STRING_BAsmFailure_Title='XXX'
  164.     ERROR_NoBAsm='XXX!'
  165.     ERROR_BASM_UnknownErrorCode='XXX!'
  166.     ERROR_BASM_NoNextErrorWarning='XXX!'
  167.     ERROR_BASM_NoErrorWarningList='XXX!'
  168.     ERROR_BASM_InLine='XXX'
  169.     ERROR_BASM_Of='XXX'
  170.     END
  171. */
  172. OTHERWISE
  173.     DO
  174.     STRING_Positive='OK'
  175.     STRING_Negative='Cancel'
  176.     STRING_Dismiss='Dismiss'
  177.     STRING_BAsmFailure_Title='BAsm error report'
  178.     ERROR_NoBAsm='The source is not yet assembled! Assemble NOW?'
  179.     ERROR_BASM_UnknownErrorCode='An unknown error occurred!'
  180.     ERROR_BASM_NoNextErrorWarning='No more errors/warnings!'
  181.     ERROR_BASM_NoErrorWarningList='No error/warnings list!'
  182.     ERROR_BASM_InLine='in line'
  183.     ERROR_BASM_Of='von'
  184.     END
  185. END
  186.  
  187. /*============================================================================*/
  188.  
  189. /*
  190. ** Prepare arguments for invocation of Assemble.ced
  191. */
  192.  
  193. IF ( Port_CygnusEd = '' ) THEN
  194.     Cmd_PORT=''
  195. ELSE
  196.     Cmd_PORT='PORT '||Port_CygnusEd
  197.  
  198. IF ( Language      = '' ) THEN
  199.     Cmd_LOCALE=''
  200. ELSE
  201.     Cmd_LOCALE='LOCALE '||Language
  202.  
  203. IF ( BAsmOptions   = '' ) THEN
  204.     Cmd_OPT=''
  205. ELSE
  206.     Cmd_OPT='OPT '||BAsmOptions
  207.  
  208. /*============================================================================*/
  209.  
  210. /*
  211. ** Finally do something 
  212. */
  213.  
  214. IF ~ SHOW('P', Port_BAsm) THEN        /* is BAsm running ? */
  215.     DO
  216.     ADDRESS VALUE Port_CygnusEd
  217.     'OKAY2 '||ERROR_NoBAsm
  218.     IF (RESULT = 1) THEN ADDRESS COMMAND 'SYS:RexxC/rx '||Assemble||' '||Cmd_PORT||' '||Cmd_LOCALE||' '||Cmd_OPT||' '
  219.     END
  220. ELSE
  221.     DO
  222.     OPTIONS FAILAT BAsmError_NoWarningList+1
  223.  
  224.     ADDRESS VALUE Port_BAsm
  225.  
  226.     IF (InvokedByAssembleScript = TRUE) THEN    /* do not step over first error/warning! */
  227.         DO
  228.  
  229.         'BINITERROR'
  230.         IF (RC = BAsmError_NoErrorList) THEN
  231.             CALL RexxSetEnv( 'BAsmError.ced', 'end' )
  232.         ELSE
  233.             CALL RexxSetEnv( 'BAsmError.ced', 'init' )
  234.  
  235.         'BINITWARNING'
  236.         IF (RC = BAsmError_NoWarningList) THEN
  237.             CALL RexxSetEnv( 'BAsmWarning.ced', 'end' )
  238.         ELSE
  239.             CALL RexxSetEnv( 'BAsmWarning.ced', 'init' )
  240.  
  241.         END
  242.  
  243.     ErrorState   = RexxGetEnv( 'BAsmError.ced' )
  244.     WarningState = RexxGetEnv( 'BAsmWarning.ced' )
  245.  
  246.     SELECT
  247.     WHEN (ErrorState = 'init') THEN    CALL RexxSetEnv( 'BAsmError.ced', 'step' )
  248.     WHEN (ErrorState = 'step') THEN
  249.         DO
  250.         'BNEXTERROR'
  251.         IF (RC = BAsmError_NoNextError) THEN
  252.             DO
  253.             CALL RexxSetEnv( 'BAsmError.ced', 'end' )
  254.             IF (WarningState = 'init') THEN CALL RexxSetEnv( 'BAsmWarning.ced', 'step' )
  255.             END
  256.         END
  257.     WHEN (ErrorState = 'end') THEN
  258.         SELECT
  259.         WHEN (WarningState = 'init') THEN CALL RexxSetEnv( 'BAsmWarning.ced', 'step' )
  260.         WHEN (WarningState = 'step') THEN
  261.             DO
  262.             'BNEXTWARNING'
  263.             IF (RC = BAsmError_NoNextWarning) THEN
  264.                 DO
  265.                 CALL RexxSetEnv( 'BAsmWarning.ced', 'end' )
  266.                 'BEND'
  267.                 ADDRESS VALUE Port_CygnusEd
  268.                 'OKAY1 '||ERROR_BASM_NoNextErrorWarning
  269.                 END
  270.             END
  271.         WHEN (WarningState = 'end') THEN 
  272.             DO
  273.             'BEND'
  274.             ADDRESS VALUE Port_CygnusEd
  275.             'OKAY1 '||ERROR_BASM_NoErrorWarningList
  276.             END
  277.         OTHERWISE Say "Internal error: Invalid warning state!"
  278.         END
  279.     OTHERWISE Say "Internal error: Invalid error state!"
  280.     END
  281.  
  282.     ErrorState   = RexxGetEnv( 'BAsmError.ced' )
  283.     WarningState = RexxGetEnv( 'BAsmWarning.ced' )
  284.  
  285.     IF ((ErrorState = 'step')|(WarningState = 'step')) THEN
  286.         DO
  287.         ADDRESS VALUE Port_BAsm
  288.  
  289.         IF (ErrorState='step') THEN 
  290.             'BGETERROR'
  291.         ELSE
  292.             'BGETWARNING'
  293.  
  294.         IF ((RC = BAsmError_OK)&(RESULT ~= '')) THEN
  295.             DO
  296.             PARSE VAR RESULT FailureLine '|' FailureOffset '|' FailureFile '|' FailureType ' ' FailureNumber ': ' FailureString '.'
  297.             ADDRESS VALUE Port_CygnusEd
  298.             'JUMP TO FILE '||FailureFile
  299.             IF (RESULT = 0) THEN        /* file with error not in any view */
  300.                 DO
  301.                 'STATUS 66'        /* total # of open views */
  302.                 IF (RESULT >= MaxViews) THEN
  303.                     DO
  304.                     'OKAY1 '||FailureType||' #'||FailureNumber||' '||ERROR_BASM_InLine||' '||FailureLine||' '||ERROR_BASM_Of||' '||FailureFile||': '||FailureString||'.'
  305.                     END
  306.                 ELSE
  307.                     DO
  308.                     'OPEN NEW'            /* make new view */
  309.                     'OPEN "'||FailureFile||'"'    /* load file with error into new view */
  310.                     'JUMP TO BYTE '||FailureOffset
  311.                     'OKAY1 '||FailureType||' #'||FailureNumber||' '||ERROR_BASM_InLine||' '||FailureLine||': '||FailureString||'.'
  312.                     END
  313.                 END
  314.             ELSE
  315.                 DO
  316.                 'JUMP TO BYTE '||FailureOffset
  317.                 'OKAY1 '||FailureType||' #'||FailureNumber||' '||ERROR_BASM_InLine||' '||FailureLine||': '||FailureString||'.'
  318.                 END
  319.             END
  320.         END
  321.     END
  322.  
  323. OPTIONS FAILAT ScriptErrorLevel
  324.  
  325. /*=============================================================================*/
  326.  
  327. END    /* IF ~ SHOW('P', Port_CygnusEd) */
  328.  
  329. EXIT
  330.  
  331. SYNTAX:
  332.  
  333. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  334. ADDRESS VALUE Port_CygnusEd
  335. 'OKAY1 Script error!'
  336. EXIT
  337.  
  338.  
  339. RexxSetEnv: PROCEDURE
  340.     PARSE ARG Name,Content
  341.  
  342.     ADDRESS COMMAND 'SetEnv "ENV:'||Name||'" "'||Content||'"'
  343.  
  344.     RETURN
  345.  
  346.  
  347. RexxGetEnv: PROCEDURE
  348.     PARSE ARG Name
  349.  
  350.     IF OPEN(EnvFile,'ENV:'||Name,'r') THEN
  351.         DO
  352.         Content = READLN(EnvFile)
  353.         CALL CLOSE EnvFile
  354.         END
  355.     ELSE Content = ""
  356.  
  357.     RETURN Content
  358.  
  359.  
  360. /*=============================================================================*/
  361.  
  362.  
  363. /*
  364. ** version history:
  365. ** ---------------
  366. **
  367. ** V1.0        : -first public version
  368. **
  369. ** V1.1        : -second public version
  370. **
  371. **          -enhanced locale handling
  372. **          -fixed port handling
  373. **          -fixed options handling
  374. **
  375. ** known bugs in the latest version/revision:
  376. ** -----------------------------------------
  377. ** - No smart localization supported. I don't know the ARexx CygnusEd command to find out the currect used language.
  378. **
  379. */
  380.  
  381.