home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / applications / wp / gedproject.lha / Project.ged next >
Encoding:
Text File  |  1995-01-23  |  15.2 KB  |  441 lines

  1. /* $VER: 1.0, ©1994 Engelbert Roidl.
  2. ** engelbert.roidl@extern.uni-regensburg.de
  3. **/
  4.  
  5. /*
  6.  *  Project.ged
  7.  *      Save windowpositions, cursorpositions and filenames.
  8.  *
  9.  *  Commands:
  10.  *      NEW   - Add a new project.
  11.  *          Request projectdirectory and projectname.
  12.  *          The user specific code in this script should set
  13.  *          up a direktory at "projectdirektory" with the name "projectname".
  14.  *          It should copy defaultfiles for your work in this direktory.
  15.  *
  16.  *      OPEN  - Opens a existing project.
  17.  *          It requests the PROJECT-file in your project's direktory.
  18.  *          After this it will open all files and it reads all important
  19.  *          files in this directory into the Project-requester form GoldEd.
  20.  *          You may modify this readprocess to use e.g. Modula or Pascal.
  21.  *
  22.  *      CLOSE - Close the current project.
  23.  *          Every time you open or add a new project you have to close it.
  24.  *          All important parameter will be saved.
  25.  *
  26.  *  Installation:
  27.  *      Make three new menu entries. Set the command type to ARexx.
  28.  *      New Project:    Cmd:    GoldEd:arexx/project.ged new
  29.  *      Open Project:   Cmd:    GoldEd:arexx/project.ged open
  30.  *      Close Project:  Cmd:    GoldEd:arexx/project.ged close
  31.  *
  32.  *  Usage:
  33.  *      1. Opening a new project:
  34.  *          Every time you want to start a new project, you have to
  35.  *          open a NEW PROJECT with this script.
  36.  *          After you have started the script via
  37.  *
  38.  *                  Golded:arexx/project.ged new
  39.  *
  40.  *          you will be asked for the projects home.
  41.  *          Select a directory (e.g. RAM:). Then you can enter the name
  42.  *          of your new project (e.g. TEST). The script will
  43.  *          make a new directory. The name will be RAM:TEST.
  44.  *          After that it changes the editors directory to this.
  45.  *
  46.  *      2. Closing a project:
  47.  *          If you have opened a new or an existing project and you
  48.  *          stop working at this day, you have to close this project via
  49.  *
  50.  *                  Golded:arexx/project.ged close
  51.  *
  52.  *          The script will save the position and file of each opened
  53.  *          window (ATTENTION: Freezed windows will not be saved!!!).
  54.  *
  55.  *      3. Opening an exsiting project:
  56.  *          If you want to start working the next day, you have to open
  57.  *          the project via
  58.  *
  59.  *                  Golded:arexx/project.ged open
  60.  *
  61.  *          You will be asked for the PROJECT-file of the project. It
  62.  *          can be found in the projects directory. In this case:
  63.  *          RAM:TEST/PROJECT.
  64.  *          Select this file via the upcoming filerequester.
  65.  *          The script changes the editors directory to the selected.
  66.  *          Then it reads the PROJECT-file and opens all windows at it's
  67.  *          old positions.
  68.  *          After that all files (pattern!!) in this directory will be
  69.  *          inserted in GoldEds Project-Requester.
  70.  *
  71.  */
  72.  
  73. OPTIONS RESULTS                             /* enable return codes     */
  74.  
  75. address 'GOLDED.1'
  76.  
  77. 'LOCK CURRENT'                              /* lock GUI, gain access   */
  78. OPTIONS FAILAT 6                            /* ignore warnings         */
  79. SIGNAL ON SYNTAX                            /* ensure clean exit       */
  80.  
  81. /* ------------------------- INSERT YOUR CODE HERE: ------------------ */
  82.  
  83. arg function    /* Arguments */
  84.  
  85. 'QUERY CAT'
  86. isGerman = (result = "deutsch")
  87.  
  88. select
  89. /******************************************************************************
  90.  * NEW
  91.  *  Open NEW Project.
  92.  ******************************************************************************/
  93.     when function = 'NEW' then
  94.     do
  95.         'QUERY USER20 VAR PRJTEST'
  96.         if (prjtest ~= TRUE) then
  97.         do /* No Project opened */
  98.             'QUERY SCREEN VAR SCR'
  99.             if (isGerman) then
  100.             do
  101.                 shell COMMAND
  102.                 'requestfile >t:dir title "Projektverzeichnis" drawersonly pubscreen ' result
  103.                 dirok = rc
  104.                 shell
  105.                 'REQUEST STRING BODY="Bitte einen Projektnamen eingeben" BUTTON="OK||Abbruch" VAR NAME'
  106.             end
  107.             else
  108.             do
  109.                 shell COMMAND
  110.                 'requestfile >t:dir title "Projectdirectory" drawersonly pubscreen ' result
  111.                 dirok = rc
  112.                 shell
  113.                 'REQUEST STRING BODY="Enter projectname" BUTTON="OK||Cancel" VAR NAME'
  114.             end
  115.  
  116.             if ( (rc = 0) & (dirok = 0) ) then
  117.             do /* Enter Directory */
  118.                 if open('dir',"t:dir", 'R') then
  119.                 do
  120.                     dir = readln('dir')
  121.  
  122.                     /* Remove Quotes */
  123.                     a = delstr(dir , 1 , 1)
  124.                     dir = delstr( a , length(a) , 1 )
  125.                     projekt = dir || name
  126.  
  127.                     /* Set Current GoldED-Directory */
  128.                     'DIR NEW' projekt
  129.  
  130.                     CALL setenv("PROJECT", projekt)
  131.  
  132.                     /* Setup Project */
  133. /****************************************************************************
  134. * Add user-specific code here
  135. ****************************************************************************/
  136.  
  137.                     /* Make Directory >projekt< */
  138.                     shell COMMAND
  139.                     'sc:c/scsetup "' || projekt || '"'
  140.                     shell
  141.                     /* Copy Defaultfiles to >projekt< */
  142.  
  143. /****************************************************************************
  144. * End user-specific code
  145. ****************************************************************************/
  146.  
  147.                     call close ('dir')
  148.                     'SET USER 20 VALUE TRUE'    /* Projekt opened */
  149.                 end
  150.             end
  151.             else
  152.             do
  153.                 'UNLOCK'
  154.                 EXIT
  155.             end
  156.         end
  157.         else
  158.         do
  159.             if (isGerman) then
  160.                 'REQUEST PROBLEM="Noch ein Projekt geöffnet||Bitte zuerst schließen"'
  161.             else
  162.                 'REQUEST PROBLEM="There is a project opened||Please close it first"'
  163.             'UNLOCK'
  164.             EXIT
  165.         end
  166.     end
  167.  
  168. /******************************************************************************
  169.  * OPEN
  170.  *  Open Projekt.
  171.  ******************************************************************************/
  172.     when function = 'OPEN' then
  173.     do
  174.         'QUERY USER20 VAR PRJTEST'
  175.         if (prjtest ~= TRUE) then
  176.         do /* No Project openend */
  177.             'QUERY SCREEN VAR SCR'
  178.             if (isGerman) then
  179.             do
  180.                 shell COMMAND
  181.                 'requestfile >t:dir title "Projekt auswählen"
  182.                              PATTERN PROJECT ACCEPTPATTERN PROJECT
  183.                              pubscreen ' result
  184.                 dirok = rc
  185.                 shell
  186.             end
  187.             else
  188.             do
  189.                 shell COMMAND
  190.                 'requestfile >t:dir title "Select Project"
  191.                              PATTERN PROJECT ACCEPTPATTERN PROJECT
  192.                              pubscreen ' result
  193.                 dirok = rc
  194.                 shell
  195.             end
  196.  
  197.             if ( dirok = 0 ) then
  198.             do /* Enter Directory */
  199.                 if open('dir',"t:dir", 'R') then
  200.                 do
  201.                     dir = readln('dir')
  202.  
  203.                     /* Remove Quotes */
  204.                     a = delstr(dir , 1 , 1)
  205.                     projekt = delstr( a , length(a) , 1 )
  206.  
  207.                     /* Remove PROJECT */
  208.                     if (right(projekt,7) = 'PROJECT') then
  209.                         projekt1 = delstr(projekt,length(projekt)-6)
  210.  
  211.                     if (right(projekt1,1) = '/') then
  212.                         projekt2 = delstr(projekt1,length(projekt1))
  213.  
  214.                     /* => projekt:  read from t:dir */
  215.                     /*    projekt1: without PROJECT */
  216.                     /*    projekt2: without / */
  217.  
  218.                     /* Current GoldED directory */
  219.                     'DIR NEW' projekt2
  220.                     CALL setenv("PROJECT", projekt2)
  221.  
  222.                     /* Setup Projectlist */
  223. /****************************************************************************
  224. * Add user-specific code here
  225. ****************************************************************************/
  226.  
  227.                     shell COMMAND
  228.                     'list >t:dd files lformat "%n" "'projekt1'#?makefile" '
  229.                     'list >>t:dd files lformat "%n" "'projekt1'#?.c"'
  230.                     'list >>t:dd files lformat "%n" "'projekt1'#?.cc"'
  231.                     'list >>t:dd files lformat "%n" "'projekt1'#?.cpp"'
  232.                     'list >>t:dd files lformat "%n" "'projekt1'#?.cxx"'
  233.                     'list >>t:dd files lformat "%n" "'projekt1'#?.a"'
  234.                     'list >>t:dd files lformat "%n" "'projekt1'#?.asm"'
  235.                     'list >>t:dd files lformat "%n" "'projekt1'#?.h"'
  236.                     'list >>t:dd files lformat "%n" "'projekt1'#?.i"'
  237.                     shell
  238.  
  239. /****************************************************************************
  240. * End user-specific code
  241. ****************************************************************************/
  242.  
  243.                     if open('files', "t:dd" , 'R') then
  244.                     do
  245.                         do while ende~=0
  246.                             file = readln('files')
  247.                             if ~eof('files') then
  248.                             do
  249.                                 'PROJECT ADD ' file
  250.                                 ende = 1
  251.                             end
  252.                             else
  253.                                 ende = 0
  254.                         end
  255.                         CALL close('files')
  256.                     end
  257.  
  258.                     if open('prj', projekt , 'R') then
  259.                     do
  260.                         anzahl = readln('prj')
  261.                         do i=1 to anzahl
  262.                             file = readln('prj')
  263.                             x = readln('prj')
  264.                             y = readln('prj')
  265.                             w = readln('prj')
  266.                             h = readln('prj')
  267.                             line = readln('prj')
  268.  
  269.                             'OPEN SMART ' file
  270.                             'GOTO LINE' line 'UNFOLD=TRUE'
  271.                             'WINDOW WIDTH ' w ' HEIGHT ' h ' X ' x ' Y ' y
  272.                         end
  273.                         call close('prj')
  274.                     end
  275.                     else
  276.                     do
  277.                         if (isGerman) then
  278.                             'REQUEST PROBLEM="Open fehlgeschlagen!"'
  279.                         else
  280.                             'REQUEST PROBLEM="Open failed!"'
  281.                         'UNLOCK'
  282.                         EXIT
  283.                     end
  284.                     call close('dir')
  285.                     'SET USER 20 VALUE TRUE'    /* Project opened */
  286.                 end
  287.                 else
  288.                 do
  289.                     CALL setenv("PROJECT", "")
  290.                     if (isGerman) then
  291.                         'REQUEST PROBLEM="Keine Projektdatei vorhanden||Bitte zuerst schließen"'
  292.                     else
  293.                         'REQUEST PROBLEM="No Projectfile available"'
  294.                     'UNLOCK'
  295.                     EXIT
  296.                 end
  297.                 CALL close(prj)
  298.  
  299.  
  300.             end
  301.         end
  302.         else
  303.         do
  304.             if (isGerman) then
  305.                 'REQUEST PROBLEM="Noch ein Projekt geöffnet||Bitte zuerst schließen"'
  306.             else
  307.                 'REQUEST PROBLEM="There is a project opened||Please close it first"'
  308.             'UNLOCK'
  309.             EXIT
  310.         end
  311.     end
  312. /******************************************************************************
  313.  * CLOSE
  314.  *  Close Project.
  315.  ******************************************************************************/
  316.     when function = 'CLOSE' then
  317.     do
  318.         'QUERY USER20 VAR PRJTEST'
  319.         if (prjtest = TRUE) then
  320.         do
  321.             path = getenv("PROJECT")
  322.  
  323.             if(right(path, 7) ~= 'PROJECT') then
  324.             do
  325.                 /* append /PROJECT */
  326.                 if (right(path,1) ~= '/' & right(path,1) ~= ':' ) then
  327.                     projekt = path || '/' || 'PROJECT'
  328.                 else
  329.                     projekt = path || 'PROJECT'
  330.             end
  331.             else
  332.                 projekt = path
  333.  
  334.             if OPEN('p', projekt , 'W') then
  335.             do
  336.                 'PROJECT CLR'
  337.                 'MORE'
  338.                 'NAME NEW RAM:OhneNamen'
  339.                 'QUERY WINDOWS VAR WINDOWSANZAHL'   /* Get Number of Windows */
  340.                 'WINDOW ORDINAL 0 QUIET'
  341.                 a = writeln('p', windowsanzahl-1)
  342.  
  343.                 do i=0 to windowsanzahl+1
  344.                     'QUERY DOC VAR WINNAME'
  345.                     'QUERY WINH VAR WINH'           /* Get Windowparameter */
  346.                     'QUERY WINW VAR WINW'
  347.                     'QUERY X VAR X'
  348.                     'QUERY Y VAR Y'
  349.                     'QUERY ABSLINE VAR LINE'
  350.  
  351.                     if( winname ~= "RAM:OhneNamen") then
  352.                     do
  353.                         a = writeln('p', winname )
  354.                         a = writeln('p', x )
  355.                         a = writeln('p', y )
  356.                         a = writeln('p', winw )
  357.                         a = writeln('p', winh )
  358.                         a = writeln('p', line )
  359.  
  360.                         /* If File modified */
  361.                         'QUERY MODIFY VAR MODIFIED'
  362.                         if(modified = TRUE) then
  363.                         do /* Request: Save File? */
  364.                             if (isGerman) then
  365.                                 'REQUEST BODY="Datei wurde verändert.|    Speichern ?" BUTTON="SAVE|Abbrechen"'
  366.                             else
  367.                                 'REQUEST BODY="File mofified.|    Save ?" BUTTON="SAVE|Abbrechen"'
  368.                             if(result = 1) then
  369.                                 'SAVE ALL'
  370.                         end
  371.                         /* Close Window */
  372.                        'QUIT FORCE'
  373.                     end
  374.                     'WINDOW NEXT QUIET'      /* Next Window */
  375.                 end
  376.                 call close('p')
  377.                 'SET USER 20 VALUE FALSE'    /* Project NOT opened */
  378.             end
  379.             else
  380.             do
  381.                 if (isGerman) then
  382.                     'REQUEST PROBLEM="Open fehlgeschlagen!"'
  383.                 else
  384.                     'REQUEST PROBLEM="Open failed!"'
  385.  
  386.                 'UNLOCK'
  387.                 EXIT
  388.             end
  389.         end
  390.         else
  391.         do
  392.             if (isGerman) then
  393.                 'REQUEST PROBLEM="Kein Projekt geöffnet"'
  394.             else
  395.                 'REQUEST PROBLEM="No Project opened"'
  396.             'UNLOCK'
  397.             EXIT
  398.         end
  399.     end
  400.  
  401.     otherwise
  402.     do
  403.         if (isGerman) then
  404.             'REQUEST PROBLEM="Unbekannte Option"'
  405.         else
  406.             'REQUEST PROBLEM="Unknown Command"'
  407.         'UNLOCK'
  408.     end
  409. end
  410.  
  411. /* ---------------------------- END OF YOUR CODE ----------------------- */
  412.  
  413. 'UNLOCK' /* VERY important: unlock GUI */
  414. EXIT
  415.  
  416. SYNTAX:
  417.  
  418. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  419. 'UNLOCK'
  420. EXIT
  421.  
  422.  
  423. getenv: procedure     /* when will ARexx supply GetEnv/SetEnv ? */
  424.    PARSE ARG name
  425.  
  426.    IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
  427.         gives = readln(TEMPFILE)
  428.         CALL close TEMPFILE
  429.         END
  430.    ELSE gives = ""
  431.  
  432.    RETURN gives
  433.  
  434. CALL setenv: procedure
  435.    PARSE ARG name,content
  436.  
  437.    ADDRESS COMMAND "SetEnv" name content
  438.  
  439.    RETURN
  440.  
  441.