home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Editor / GED403R.LZX / Install / Install.run / GOLDEDDATA / arexx / rev.ged < prev    next >
Encoding:
Text File  |  1996-07-18  |  7.0 KB  |  215 lines

  1. /* 
  2. ** $VER: revision 0.010 (02 Feb 1994) ***
  3. **
  4. ** (c) 1993 Marius Gröger
  5. **
  6. ** NAME
  7. **    revision
  8. **
  9. ** FUNCTION
  10. **    Arexx-Script for GoldEd.
  11. **
  12. **    Revision a Source-Code/Script/...-File in our new style.
  13. **    Process a History.
  14. **
  15. ** SYNOPSIS
  16. **    revision HISTORY/K,GOAWAY/K,AUTO/S
  17. **
  18. ** INPUTS
  19. **    HISTORY - Set TRUE for history processing
  20. **    AUTO    - Set TRUE for automatic history processing
  21. **    GOAWAY  - Set TRUE to leave Editor after (successfull) revision
  22. **
  23. **    HISTORY - TRUE pour la génération de l'historique
  24. **    AUTO    - TRUE pour la génération automatique de l'historique
  25. **    GOAWAY  - TRUE pour quitter l'Editeur après une révision (réussie)
  26. **
  27. **    Set switches to 'TRUE' if you want to turn them on.
  28. **    Définissez ces switches sur 'TRUE' si vous voulez les activer.
  29. **
  30. ** $HISTORY:
  31. **
  32. ** 02 Feb 1994 : 000.010 :  considers white space settings
  33. ** 17 Sep 1993 : 000.009 :  now keeps rest of line untouched (Kössi)
  34. ** 21 Jul 1993 : 000.008 :  some small enhancements (D.Eilert)
  35. ** 19 Jul 1993 : 000.007 :  fixed bug which appeared with special header-layouts
  36. ** 19 Jul 1993 : 000.006 :  now saves search pattern and case-flag
  37. ** 19 Jul 1993 : 000.005 :  wrong example in Error requester fixed
  38. ** 18 Jul 1993 : 000.004 :  localized title-text
  39. ** 18 Jul 1993 : 000.003 :  added commandline args
  40. ** 18 Jul 1993 : 000.002 :  added history handling
  41. ** 16 Jul 1993 : 000.001 :  initial release
  42. */
  43.  
  44. OPTIONS RESULTS                             /* enable return codes     */
  45. arg doHistory goAway autoHistory
  46.  
  47. if (LEFT(ADDRESS(), 6) ~= "GOLDED") then    /* not started by GoldEd ? */
  48.     address 'GOLDED.1'
  49.  
  50. 'LOCK CURRENT RELEASE=4'                    /* lock GUI, gain access   */
  51. if (RC ~= 0) then
  52.     exit
  53.  
  54. OPTIONS FAILAT 6                            /* ignore warnings         */
  55. SIGNAL ON SYNTAX                            /* ensure clean exit       */
  56.  
  57. /* ----------------------- INSERT YOUR CODE HERE: -------------------- */
  58.  
  59. changed = 0                                     /* something to save ? */
  60.  
  61. 'QUERY CAT'                                          /* query language */
  62.  
  63. if (result = "deutsch") then do
  64.  
  65.    noText    = '"Es ist kein Text im Editor ?!"'
  66.    noHistory = '"Text hat keine History-Kennung*nFormat: $HISTORY:"'
  67.    noVersion = '"Text hat keine Standard-Versionskennung!*nBeispiel: $VER: Name 40.1 (9 Feb 93)"'
  68.    comment   = '"Kommentar zur Version '
  69. end
  70. else if (result = "français") then do
  71.  
  72.    noText    = '"Pas de texte dans le tampon ?!"'
  73.    noHistory = '"Mot-clé de l''Historique manquant|Format: $HISTORY:"'
  74.    noVersion = '"Mot-clé de la version manquant|Exemple: $VER: Nom 40.1 (9 Fev 93)"'
  75.    comment   = '"Commentaire sur la version '
  76. end
  77. else do
  78.  
  79.    noText    = '"No text in buffer ?!"'
  80.    noHistory = '"History keyword missing*nFormat: $HISTORY:"'
  81.    noVersion = '"Version keyword missing*nExample: $VER: Name 40.1 (9 Feb 93)"'
  82.    comment   = '"Comment about version '
  83. end
  84.  
  85. 'QUERY ANYTEXT'
  86.  
  87. if (result = 'TRUE') then do              /* Only if there is any text */
  88.  
  89.    'PING SLOT=0'                               /* save cursor position */
  90.    'MARK HIDE'                                    /* no blocks, please */
  91.    'QUERY FIND VAR SPAT'                          /* remember settings */
  92.    'QUERY USECASE VAR USECASE'
  93.    'QUERY SPC VAR SPACE'
  94.  
  95.     /* ------------------ Part I: Version processing ----------------- */
  96.  
  97.    'FOLD ALL OPEN=TRUE'                                  /* open folds */
  98.    'FIND FIRST CASE=TRUE QUIET STRING="$VER:"'    /* search version id */
  99.  
  100.    if (RC = 0) then do                                     /* found ?? */
  101.  
  102.       'SET SPC 32'                               /* set word separator */
  103.  
  104.       'NEXT'                                       /* skip id and name */
  105.       'NEXT'
  106.  
  107.       'QUERY WORD VAR VER'       /* what is the word we are over now ? */
  108.  
  109.       /* we must make shure that this is a version.revision number     */
  110.       /* we do this by checking the existance of a full stop ('.')     */
  111.  
  112.       if (pos('.',ver) ~= 0) then do
  113.  
  114.          version  = left(ver, pos('.', ver) - 1)
  115.          revision = right(ver, length(ver) - pos('.', ver)) + 1
  116.  
  117.          if (revision < 10) then 
  118.              revision = '00' || revision
  119.          else if (revision < 100) then 
  120.              revision = '0' || revision
  121.  
  122.          ver = version || '.' || revision
  123.  
  124.          'DELETE WORD'                    /* delete old revision string */
  125.          'TEXT T="' || ver || '"'           /* insert new into the text */
  126.  
  127.          'RIGHT'                        /* move over "(" of date string */
  128.  
  129.          'SET EXCLUDE FALSE'
  130.  
  131.          'MARK SET COLUMN'
  132.  
  133.          'BRACKET MATCH'                            /* find end of date */
  134.  
  135.          'MARK SET COLUMN EXCLUDE=FALSE'             /* delete old date */
  136.  
  137.          'DELETE BLOCK'
  138.  
  139.          ver = '(' || date() || ')'                         /* new date */
  140.          'TEXT T="' || ver || '"'            /* insert it into the text */
  141.  
  142.          changed  = 1                      /* we have something to save */
  143.  
  144.          /* ----------------- Part II: History processing ------------- */
  145.  
  146.          if ((doHistory = 'TRUE') | (autoHistory = 'TRUE')) then do
  147.  
  148.             'FIND FIRST CASE=TRUE QUIET STRING="$HISTORY:"' 
  149.  
  150.             if (RC = 0) then do                              /* found ? */
  151.  
  152.                'DOWN'                   /* skip $HISTORY and empty line */
  153.                'DOWN'   
  154.                'LINES DOUBLE'                    /* double last comment */
  155.                'DELETE EOL'                      /* delete rest of line */
  156.  
  157.                'TEXT T="' || RIGHT(date(), 11, ' ') || ' : ' || right(version, 3 ,'0') || '.' || right(revision, 3, '0') || ' :  "'
  158.  
  159.                changed = 1                 /* we have something to save */
  160.  
  161.                'REQUEST STRING TITLE=' || comment || version || '.' || revision || '"'
  162.  
  163.                comment = RESULT
  164.  
  165.                if ((RC = 5) | (comment = '')) then      /* lazy today ? */
  166.                   comment = '- no comment -'
  167.  
  168.                'FIX VAR=COMMENT'
  169.  
  170.                'TEXT T="' || comment '"'            /* insert log entry */
  171.  
  172.             end
  173.             else if (autoHistory ~= 'TRUE') then          /* complain ? */
  174.  
  175.                'REQUEST PROBLEM=' || noHistory
  176.  
  177.          end                                       /* of 'if doHistory' */
  178.       end
  179.       else
  180.          'REQUEST PROBLEM=' || noVersion
  181.    end
  182.    else
  183.        'REQUEST PROBLEM=' || noVersion
  184.  
  185.    /* restore several settings (cursor position, find string, ... */
  186.  
  187.    'FIX VAR=SPACE'                                   /* replace * by ** */
  188.    'SET SPC="' || SPACE || '"'
  189.    'PONG SLOT=0'
  190.    'FIND STRING="' || spat || '" CASE=' || usecase
  191.  
  192.    /* something to save? */
  193.  
  194.    if (changed) then do
  195.  
  196.        if (goAway = 'TRUE') then
  197.            'SAVE ALL EXIT'
  198.        else
  199.           'SAVE ALL'
  200.    end
  201. end 
  202. else                                               /* no text in buffer */
  203.    'REQUEST PROBLEM=' || noText
  204.  
  205. /* -------------------------- END OF YOUR CODE ------------------------ */
  206.  
  207. 'UNLOCK' /* VERY important: unlock GUI */
  208. EXIT
  209.  
  210. SYNTAX:
  211.  
  212. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  213. 'UNLOCK'
  214. EXIT
  215.