home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / ME494-3.ZIP / PVCS.SRC < prev    next >
Encoding:
Text File  |  1990-04-27  |  13.9 KB  |  452 lines

  1. $MACRO_FILE PVCS;
  2. {*************************MULTI-EDIT MACRO FILE******************************
  3. Contains the PVCS interface macros.
  4. To configure Multi-Edit to interface to the PVCS system, place the
  5. following commands in your STARTUP macro:
  6.  
  7.                 {Tell Multi-Edit to utilize the PVCS_GET_FILE macro if a
  8.                  FILE NOT FOUND error occurs when the user loads a file.}
  9.     set_global_str('@FNF_LOAD_MACRO@', 'PVCS^PVCS_GET_FILE');
  10.  
  11.                 {Setup the switches to use for checking out a file.
  12.                  -L is the default switch.  If you do not want the file
  13.                  locked, then you can use the -W switch.}
  14.     set_global_str('!PVCS_GET_SWITCHES!', '-L' );
  15.  
  16.                 {Tell Multi-Edit to call the PVCS_CLEANUP macro before
  17.                  exiting.  Only use this if you want to be prompted to
  18.                  check files back in before exiting.}
  19.     set_global_str('@ME_EXIT_MACRO@', 'PVCS^PVCS_CLEANUP');
  20.  
  21.  
  22. The macro PVCS_MENU supplies a menu from which the user can list available
  23. log files, check out files from that list, and check the current file back
  24. in.
  25.  
  26. PVCS                    - Polytron PVCS interface menu
  27. PVCS_GET_FILE - Loads PVCS files
  28. PVCS_DIR            - Displays a directory of PVCS files
  29. PVCS_CLEANUP    - Works with ME's exit routine to be sure PVCS issues are resolved
  30. PVCS_MENU            - Checkin/Checkout for PVCS files
  31.  
  32.                              (C) Copyright 1989 by American Cybernetics, Inc.
  33. ******************************************************************************}
  34.  
  35. $MACRO PVCS;
  36. {*******************************MULTI-EDIT MACRO******************************
  37.  
  38. Name: PVCS
  39.  
  40. Description: Polytron PVCS Inteface macro.
  41.  
  42. Parameters:   /C=str    Command string
  43.                                  CHECKOUT check out file
  44.                                  CHECKIN  check file back in
  45.  
  46.                             /F=str    File name
  47.  
  48.                              (C) Copyright 1989 by American Cybernetics, Inc.
  49. ******************************************************************************}
  50.     def_str( cmd[20],
  51.                      fname[120],
  52.                      tstr[120],
  53.                      pvcs_name[120],
  54.                      switches[40]
  55.                  );
  56.  
  57.     def_int( old_win, pvcs_win, initial_rev, checkout_count, jx, file_win,
  58.                     multi_line_comment );
  59.  
  60.         {IF you want multiple line comments for PVCS then set this variable to
  61.             TRUE}
  62.     multi_line_comment := FALSE;
  63.  
  64.     cmd := shorten_str(parse_str( '/C=', mparm_str ));
  65.     fname := parse_str( '/F=', mparm_str );
  66.     IF fname = '' THEN
  67.         fname := file_name;
  68.     ELSE
  69.         fname := fexpand(fname);
  70.     END;
  71.     refresh := false;
  72.  
  73.     old_win := window_id;
  74.     switch_window( window_count );
  75.     create_window;
  76.     pvcs_win := window_id;
  77.     pvcs_name := me_path + user_id + 'PVCS.TMP';
  78.     IF switch_file( pvcs_name ) THEN
  79.         delete_window;
  80.     END;
  81.     switch_win_id( pvcs_win );
  82.     reg_exp_stat := TRUE;
  83.  
  84.     checkout_count := Global_Int('!PVCS_CHECKOUT_COUNT!');
  85.  
  86.     IF cmd = 'CHECKOUT' THEN
  87.         RM('userin^CHECKFILE');
  88.         IF return_int < 1 THEN
  89.             goto exit;
  90.         END;
  91.         make_message('');
  92.         Working;
  93.         switches := Global_Str('!PVCS_GET_SWITCHES!');
  94.         IF switches = '' THEN
  95.             switches := '-L';
  96.         END;
  97.         gotoxy( message_col, message_row );
  98.         make_message('Retrieving "' + truncate_path(fname) + '"...');
  99.         shell_to_dos( 'RSE GET ' + switches + ' ' + fname + ' > ' + pvcs_name, TRUE );
  100.         IF error_level <> 0 THEN
  101.             return_int := 0;
  102.             goto ERROR_EXIT;
  103.         END;
  104.         load_file( pvcs_name );
  105.         IF error_level <> 0 THEN
  106.             return_int := 0;
  107.             goto ERROR_EXIT;
  108.         END;
  109.         IF (search_fwd('get:',0)) THEN
  110.             RM('MEERROR^MESSAGEBOX /T=PVCS ERROR/B=2/M=' + get_line );
  111.             return_int := 0;
  112.             goto ERROR_exit;
  113.         END;
  114.         IF (search_fwd('@<@-',0)) THEN
  115.             goto_col(1);
  116.             fname := fexpand(get_word(' '));
  117.             right; right; right; right;
  118.             tstr := get_word(' ');
  119.             switch_win_id( old_win );
  120.             load_file( fname );
  121.             RM('EXTSETUP');
  122.             return_int := 1;
  123.             make_message( '"' + truncate_path(file_name) + '" checked out of "' + tstr + '".');
  124.             ++checkout_count;
  125.             Set_Global_Str('!PVCS_FILE_OUT#' + str(checkout_count), file_name );
  126.         ELSE
  127.             goto parse_problem;
  128.         END;
  129.  
  130.     ELSIF cmd = 'CHECKIN' THEN
  131.         return_str := get_extension( fname );
  132.         IF length(return_str) = 1 THEN
  133.             return_str := return_str + '_V';
  134.         ELSE
  135.             return_str := copy(return_str,1,2) + 'V';
  136.         END;
  137.         initial_rev := (file_exists( truncate_extension(fname) + '.' + return_str) = FALSE);
  138.  
  139.  
  140.  
  141.         IF multi_line_comment THEN
  142.             switch_window( window_count );
  143.             create_window;
  144.             file_name := me_path + user_id + '2PVCS.TMP';
  145.             Return_Str := '';
  146.             IF initial_rev THEN
  147.                 RM('USERIN^EDITWINDOW /X=5/Y=5/W=60/L=10/WW=1/RM=58/CC=1/SP=1/T=PVCS:  DESCRIBE "' + truncate_path(fname) + '"/W=70/ML=128/B=1');
  148.                 switches := ' -T';
  149.             ELSE
  150.                 RM('USERIN^EDITWINDOW /X=5/Y=5/W=60/L=10/WW=1/RM=58/CC=1/SP=1/T=PVCS:  DESCRIBE CHANGES TO"' + truncate_path(fname) + '"/W=70/ML=128/B=1');
  151.                 switches := ' -M';
  152.             END;
  153.             save_file;
  154.             delete_window;
  155.             switch_win_id( pvcs_win );
  156.             RM('USERIN^VERIFY /T=Check "' + fname + '" into library?');
  157.         ELSE
  158.             Return_Str := '';
  159.             IF initial_rev THEN
  160.                 RM('USERIN^USERSTR /BL=PVCS:  DESCRIBE "' + truncate_path(fname) + '"/W=70/ML=128/B=1');
  161.                 switches := ' -T';
  162.             ELSE
  163.                 RM('USERIN^USERSTR /BL=PVCS:  DESCRIBE CHANGES TO "' + truncate_path(fname) + '"/W=70/ML=128/B=1');
  164.                 switches := ' -M';
  165.             END;
  166.             tstr := return_str;
  167.         END;
  168.         IF return_int THEN
  169.             working;
  170.             file_win := 0;
  171.             IF switch_file( fname ) THEN
  172.                 file_win := window_id;
  173.                 IF file_changed THEN
  174.                     RM('MEUTIL1^SAVEFILE /NP=1');
  175.                 END;
  176.                 RM('WINDOW^DelWin');
  177.                 IF old_win = file_win THEN
  178.                     old_win := window_id;
  179.                 END;
  180.             END;
  181.  
  182.             jx := 1;
  183.             WHILE (jx <= checkout_count) AND
  184.                         (Global_Str('!PVCS_FILE_OUT#' + str(jx)) <> fname) DO
  185.                 ++jx;
  186.             END;
  187.             IF jx <= checkout_count THEN
  188.                 return_int := jx;
  189.                 RM('USERIN^DELETEITEM /G=!PVCS_FILE_OUT#/#=' + str(checkout_count) );
  190.                 --checkout_count;
  191.             END;
  192.             switch_win_id( pvcs_win );
  193.             make_message('');
  194.             Working;
  195.             gotoxy( message_col, message_row );
  196.             make_message('Storing "' + truncate_path(fname) + ' "...');
  197.             IF NOT(multi_line_comment) THEN
  198.                 shell_to_dos( 'RSE PUT ' + switches + '"' + tstr + '" ' + fname + ' > ' + pvcs_name, TRUE );
  199.             ELSE
  200.                 shell_to_dos( 'RSE PUT ' + switches + '@' + me_path + user_id + '2PVCS.TMP ' + fname + ' > ' + pvcs_name, TRUE );
  201.             END;
  202.             IF error_level <> 0 THEN
  203.                 return_int := 0;
  204.                 goto ERROR_EXIT;
  205.             END;
  206.             load_file( pvcs_name );
  207.             IF error_level <> 0 THEN
  208.                 return_int := 0;
  209.                 goto ERROR_EXIT;
  210.             END;
  211.             IF (search_fwd('%put:',0)) THEN
  212.                 RM('MEERROR^MESSAGEBOX /T=PVCS ERROR/B=2/M=' + get_line );
  213.                 return_int := 0;
  214.                 goto ERROR_exit;
  215.             ELSE
  216.                 tof;
  217.                 IF (search_fwd('@-@>',0)) THEN
  218.                     goto_col(1);
  219.                     fname := fexpand(get_word(' '));
  220.                     right; right; right; right;
  221.                     tstr := get_word(' ');
  222.                     return_int := 1;
  223.                     make_message( '"' + truncate_path(fname) + '" checked in to "' + tstr + '".');
  224.                 ELSE
  225.          parse_problem:
  226.                     return_int := 0;
  227.                     make_message('Problem parsing PVCS message file.');
  228.                     goto exit2;
  229.                 END;
  230.             END;
  231.         END;
  232.     END;
  233.     GOTO EXIT;
  234.  
  235. ERROR_EXIT:
  236.     make_message('Error occurred during PVCS operation.');
  237. EXIT:
  238.     IF switch_win_id( pvcs_win ) THEN
  239.         delete_window;
  240.     END;
  241.     switch_win_id( old_win );
  242. EXIT2:
  243.     set_global_int('!PVCS_CHECKOUT_COUNT!', checkout_count );
  244. END_MACRO;
  245.  
  246. $MACRO PVCS_GET_FILE;
  247. {*******************************MULTI-EDIT MACRO******************************
  248.  
  249. Name: PVCS_GET_FILE
  250.  
  251. Description: Called from the LDFILES macro if the file was not found.  This
  252.     will search for a PVCS log file, and ask the user if he wants to retrieve
  253.     the latest revision.
  254.  
  255.                              (C) Copyright 1989 by American Cybernetics, Inc.
  256. ******************************************************************************}
  257.  
  258.     def_str( tstr[120], gstr[20], new_ext[3] );
  259.     tstr := truncate_path(parse_str('/F=',mparm_str));
  260.     new_ext := get_extension( tstr );
  261.     RM( 'FIND_EXT /EXT=.' + new_ext );
  262.     gstr := return_str;
  263.     return_str := parse_str('DIR=',Global_Str(gstr));
  264.     IF svl(new_ext) = 1 THEN
  265.         new_ext := new_ext + '_V';
  266.     ELSE
  267.         new_ext := copy(new_ext,1,2) + 'V';
  268.     END;
  269.     RM('PathSearch /F=' + truncate_extension(tstr) + '.' + new_ext );
  270.     IF return_int THEN
  271.         RM('USERIN^VERIFY /BL=PVCS: "' + tstr + '" not found/T=Get from "' + return_str + '"?');
  272.         IF return_Int then
  273.             RM('PVCS /C=CHECKOUT/F=' + get_path(return_str) + truncate_path(tstr));
  274.             return_int := 1;
  275.         END;
  276.     ELSE
  277.         return_int := 0;
  278.     END;
  279. END_MACRO;
  280.  
  281. $MACRO PVCS_DIR TRANS;
  282. {******************************MULTI-EDIT MACRO******************************
  283.  
  284. Name: PVCS_DIR
  285.  
  286. Description: Displays directory listing of PVCS log files.  Allows you to
  287.     select a file to be retrieved.
  288.  
  289.                              (C) Copyright 1989 by American Cybernetics, Inc.
  290. *****************************************************************************}
  291.  
  292.     def_int(bc, old_win, new_win);
  293.     bc := parse_int( '/BC=', mparm_str );
  294.     RM('DIRSHELL /S=2/W=48/L=100/D=' + get_path(global_str('!PVCS_DIR!')) + '*.??V' + mparm_str );
  295.     set_global_str('!PVCS_DIR!', return_str);
  296.     IF return_int > 0 THEN
  297.         old_win := window_id;
  298.         RM('CreateWindow');
  299.         new_win := window_id;
  300.         IF error_level = 0 THEN
  301.             While box_count > bc DO
  302.                 kill_box;
  303.             END;
  304.             RM('PVCS /C=CHECKOUT/F=' + return_str);
  305.             IF return_int = 0 THEN
  306.                 switch_win_id( new_win );
  307.                 delete_window;
  308.                 switch_win_id( old_win );
  309.             END;
  310.         END;
  311.         RETURN_INT := 100;
  312.     END;
  313. END_MACRO;
  314.  
  315. $MACRO PVCS_CLEANUP TRANS;
  316. {******************************MULTI-EDIT MACRO******************************
  317.  
  318. Name: PVCS_CLEANUP
  319.  
  320. Description: Checks to see if there are any PVCS files still checked out and
  321.                          prompts user for what to do.  Done just prior to exiting ME.
  322.  
  323.                              (C) Copyright 1989 by American Cybernetics, Inc.
  324. *****************************************************************************}
  325.  
  326.     def_int( checkout_count, jx, old_win );
  327.  
  328.     refresh := false;
  329.     checkout_count := Global_Int('!PVCS_CHECKOUT_COUNT!');
  330.     IF checkout_count < 1 THEN
  331.         return_int := 1;
  332.         goto exit;
  333.     END;
  334.     old_win := window_id;
  335.     switch_window( window_count );
  336.     create_window;
  337.     jx := 0;
  338.     WHILE jx < checkout_count DO
  339.         ++jx;
  340.         put_line( Global_Str('!PVCS_FILE_OUT#' + str(jx) ));
  341.         down;
  342.     END;
  343.     tof;
  344.     Set_Global_Str('EVPVCS1', '/T=Check files back in/K1=13/K2=28/R=1');
  345.     Set_Global_Str('EVPVCS2', '/T=Exit without checking files in/KC=<SPACE>/K1=32/K2=57/R=2');
  346.     Set_Global_Str('EVPVCS3', '/T=Cancel, don''t exit Multi-Edit/K1=27/K2=1/R=0');
  347.     RM('WMENU /T=PVCS: FILES CHECKED OUT/EV=EVPVCS/EV#=3');
  348.     delete_window;
  349.     switch_win_id( old_win );
  350.     IF return_int = 1 THEN
  351.         jx := checkout_count;
  352.         while jx > 0 DO
  353.             RM('PVCS /C=CHECKIN/F=' + global_str('!PVCS_FILE_OUT#' + str(jx)));
  354.             --jx;
  355.         END;
  356.     END;
  357. EXIT:
  358. END_MACRO;
  359.  
  360. $MACRO PVCS_MENU TRANS;
  361. {******************************MULTI-EDIT MACRO******************************
  362.  
  363. Name: PVCS_MENU
  364.  
  365. Description: Provides a menu of available PVCS files for check out.
  366.  
  367.                              (C) Copyright 1989 by American Cybernetics, Inc.
  368. *****************************************************************************}
  369.  
  370.     def_str( gstr[20] );
  371.     refresh := false;
  372.     gstr := '!PVCS!_';
  373.     Create_Global_Str(gstr+'1','/H=/M=PVCS_DIR');
  374.     Create_Global_Str(gstr+'X1','List log files available for check out');
  375.     Create_Global_Str(gstr+'2','/S=2/M=PVCS /C=CHECKIN');
  376.     Create_Global_Str(gstr+'X2','Put current file into log (check file in)');
  377. do_xmenu:
  378.     RM('USERIN^SUBMENU /GCLR=1/#=2/M=' + gstr + 'X' + '/S=' +global_str(gstr+'0') +'/L=PVCS INTERFACE MENU/G=' + gstr + MParm_Str);
  379. END_MACRO;
  380.  
  381. $MACRO PVCSInstall TRANS;
  382. {******************************MULTI-EDIT MACRO******************************
  383.  
  384. Name: PVCSInstall
  385.  
  386. Description: Sets up the user's STARTUP.SRC file for PVCS.
  387.  
  388.                              (C) Copyright 1989 by American Cybernetics, Inc.
  389. *****************************************************************************}
  390.     def_int( old_win );
  391.  
  392.     refresh := false;
  393.     old_win := window_id;
  394.     create_window;
  395.     return_str := 'STARTUP.SRC';
  396.     RM('LdFiles');
  397.     IF NOT(return_int) THEN
  398.         return_str := me_path + 'SRC\STARTUP.SRC';
  399.         RM('LdFiles');
  400.         IF NOT(return_int) THEN
  401.             RM('MEERROR^MessageBox /B=2/M=Unable to locate STARTUP.SRC.  PVCS installation not complete.');
  402.             goto exit;
  403.         END;
  404.     END;
  405.     IF search_fwd('Setup for PVCS',0) THEN
  406.         RM('MEERROR^MessageBox /B=1/M=STARTUP.SRC already contains PVCS setup.');
  407.         goto exit;
  408.     END;
  409.     IF search_fwd('END_MACRO;', 0) THEN
  410.         goto_col(1);
  411.         set_indent_level;
  412.         CR;
  413.         up;
  414.         Text('{************** Setup for PVCS ***************}'); CR;
  415. Text('                {Tell Multi-Edit to utilize the PVCS_GET_FILE macro if a'); CR;
  416. Text('                 FILE NOT FOUND error occurs when the user loads a file.}'); CR;
  417. Text('    set_global_str(''@FNF_LOAD_MACRO@'', ''PVCS^PVCS_GET_FILE'');'); CR;
  418.     set_global_str('@FNF_LOAD_MACRO@', 'PVCS^PVCS_GET_FILE');
  419. CR;
  420. Text('                {Setup the switches to use for checking out a file.'); CR;
  421. Text('                 -L is the default switch.  If you do not want the file'); CR;
  422. Text('                 locked, then you can use the -W switch.}'); CR;
  423. Text('    set_global_str(''!PVCS_GET_SWITCHES!'', ''-L'' );'); CR;
  424.     set_global_str('!PVCS_GET_SWITCHES!', '-L' );
  425. CR;
  426. Text('                {Tell Multi-Edit to call the PVCS_CLEANUP macro before'); CR;
  427. Text('                 exiting.  Only use this if you want to be prompted to'); CR;
  428. Text('                 check files back in before exiting.}'); CR;
  429. Text('    set_global_str(''@ME_EXIT_MACRO@'', ''PVCS^PVCS_CLEANUP'');'); CR;
  430.     set_global_str('@ME_EXIT_MACRO@', 'PVCS^PVCS_CLEANUP');
  431.         Text('{*********************************************}'); CR;
  432.  
  433.         Save_File;
  434.         Return_Str := me_path + 'MEMAC -P' + me_path + ' ' + file_name + ' > ' +
  435.                                     me_path + user_id + 'SETER.TMP';
  436.         RM('EXEC /CMD=1/SWAP=4/MEM=120');
  437.         IF error_level = 0 THEN
  438.             load_file(me_path + user_id + 'SETER.TMP');
  439.             IF error_level = 0 THEN
  440.                 IF search_fwd('ERROR',0) THEN
  441.                     RM('MEERROR^MessageBox /B=2/M=Error occurred compiling SETUP.SRC.');
  442.                     goto exit;
  443.                 END;
  444.             END;
  445.         END;
  446.         RM('MEERROR^MessageBox /M=Your STARTUP macro has been modified to initialize the PVCS support.');
  447.     END;
  448. EXIT:
  449.     delete_window;
  450.     switch_win_id( old_win );
  451. END_MACRO;
  452.