home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games 1995 January / amigagames-1995-01.iso / archive / userbox / publicdomain / ged313.lha / Install / data / main / GoldED / arexx / rev.ged < prev    next >
Text File  |  1995-03-20  |  7KB  |  205 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'                              /* lock GUI, gain access   */
  51. OPTIONS FAILAT 6                            /* ignore warnings         */
  52. SIGNAL ON SYNTAX                            /* ensure clean exit       */
  53.  
  54. /* ----------------------- INSERT YOUR CODE HERE: -------------------- */
  55.  
  56. changed = 0                                     /* something to save ? */
  57.  
  58. 'QUERY CAT'                                          /* query language */
  59.  
  60. if (result = "deutsch") then do
  61.  
  62.    noText    = '"Es ist kein Text im Editor ?!"'
  63.    noHistory = '"Text hat keine History-Kennung*nFormat: $HISTORY:"'
  64.    noVersion = '"Text hat keine Standard-Versionskennung!*nBeispiel: $VER: Name 40.1 (9 Feb 93)"'
  65.    comment   = '"Kommentar zur Version '
  66. end
  67. else if (result = "français") then do
  68.  
  69.    noText    = '"Pas de texte dans le tampon ?!"'
  70.    noHistory = '"Mot-clé de l''Historique manquant|Format: $HISTORY:"'
  71.    noVersion = '"Mot-clé de la version manquant|Exemple: $VER: Nom 40.1 (9 Fev 93)"'
  72.    comment   = '"Commentaire sur la version '
  73. end
  74. else do
  75.  
  76.    noText    = '"No text in buffer ?!"'
  77.    noHistory = '"History keyword missing*nFormat: $HISTORY:"'
  78.    noVersion = '"Version keyword missing*nExample: $VER: Name 40.1 (9 Feb 93)"'
  79.    comment   = '"Comment about version '
  80. end
  81.  
  82. 'QUERY ANYTEXT'
  83.  
  84. if (result = 'TRUE') then do              /* Only if there is any text */
  85.  
  86.    'PING SLOT=0'                               /* save cursor position */
  87.    'MARK HIDE'                                    /* no blocks, please */
  88.    'QUERY FIND VAR SPAT'                          /* remember settings */
  89.    'QUERY USECASE VAR USECASE'
  90.    'QUERY SPC VAR SPACE'
  91.  
  92.     /* ------------------ Part I: Version processing ----------------- */
  93.  
  94.    'FOLD ALL OPEN=TRUE'                                  /* open folds */
  95.    'FIND FIRST CASE=TRUE QUIET STRING="$VER:"'    /* search version id */
  96.  
  97.    if (RC = 0) then do                                     /* found ?? */
  98.  
  99.       'GUI SPC=32'                               /* set word separator */
  100.  
  101.       'NEXT'                                       /* skip id and name */
  102.       'NEXT'
  103.  
  104.       'QUERY WORD VAR VER'       /* what is the word we are over now ? */
  105.  
  106.       /* we must make shure that this is a version.revision number     */
  107.       /* we do this by checking the existance of a full stop ('.')     */
  108.  
  109.       if (pos('.',ver) ~= 0) then do
  110.  
  111.          version  = left(ver, pos('.', ver) - 1)
  112.          revision = right(ver, length(ver) - pos('.', ver)) + 1
  113.  
  114.          if (revision < 10) then 
  115.              revision = '00' || revision
  116.          else if (revision < 100) then 
  117.              revision = '0' || revision
  118.  
  119.          ver = version || '.' || revision
  120.  
  121.          'DELETE WORD'                    /* delete old revision string */
  122.          'TEXT T="' || ver || '"'           /* insert new into the text */
  123.  
  124.          'RIGHT'                        /* move over "(" of date string */
  125.          'MARK SET COLUMN EXCLUDE=FALSE'
  126.          'BRACKET MATCH'                            /* find end of date */
  127.          'MARK SET COLUMN EXCLUDE=FALSE'             /* delete old date */
  128.          'DELETE BLOCK'
  129.  
  130.          ver = '(' || date() || ')'                         /* new date */
  131.          'TEXT T="' || ver || '"'            /* insert it into the text */
  132.  
  133.          changed  = 1                      /* we have something to save */
  134.  
  135.          /* ----------------- Part II: History processing ------------- */
  136.  
  137.          if ((doHistory = 'TRUE') | (autoHistory = 'TRUE')) then do
  138.  
  139.             'FIND FIRST CASE=TRUE QUIET STRING="$HISTORY:"' 
  140.  
  141.             if (RC = 0) then do                              /* found ? */
  142.  
  143.                'DOWN'                   /* skip $HISTORY and empty line */
  144.                'DOWN'   
  145.                'LINE DOUBLE'                     /* double last comment */
  146.                'DELETE EOL'                      /* delete rest of line */
  147.  
  148.                'TEXT T="' || RIGHT(date(), 11, ' ') || ' : ' || right(version, 3 ,'0') || '.' || right(revision, 3, '0') || ' :  "'
  149.  
  150.                changed = 1                 /* we have something to save */
  151.  
  152.                'REQUEST STRING TITLE=' || comment || version || '.' || revision || '"'
  153.                comment = RESULT
  154.  
  155.                if ((RC = 5) | (comment = '')) then      /* lazy today ? */
  156.                   comment = '- no comment -'
  157.  
  158.                'FIX VAR=COMMENT'
  159.  
  160.                'TEXT T="' || comment '"'            /* insert log entry */
  161.  
  162.             end
  163.             else if (autoHistory ~= 'TRUE') then          /* complain ? */
  164.  
  165.                'REQUEST PROBLEM=' || noHistory
  166.  
  167.          end                                       /* of 'if doHistory' */
  168.       end
  169.       else
  170.          'REQUEST PROBLEM=' || noVersion
  171.    end
  172.    else
  173.        'REQUEST PROBLEM=' || noVersion
  174.  
  175.    /* restore several settings (cursor position, find string, ... */
  176.  
  177.    'FIX VAR=SPACE'                                   /* replace * by ** */
  178.    'GUI SPC="' || SPACE || '"'
  179.    'PONG SLOT=0'
  180.    'FIND STRING="' || spat || '" CASE=' || usecase
  181.  
  182.    /* something to save? */
  183.  
  184.    if (changed) then do
  185.  
  186.        if (goAway = 'TRUE') then
  187.            'SAVE ALL EXIT'
  188.        else
  189.           'SAVE ALL'
  190.    end
  191. end 
  192. else                                               /* no text in buffer */
  193.    'REQUEST PROBLEM=' || noText
  194.  
  195. /* -------------------------- END OF YOUR CODE ------------------------ */
  196.  
  197. 'UNLOCK' /* VERY important: unlock GUI */
  198. EXIT
  199.  
  200. SYNTAX:
  201.  
  202. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  203. 'UNLOCK'
  204. EXIT
  205.