home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cons-010.zip / Console / install.cmd < prev    next >
OS/2 REXX Batch file  |  1997-10-02  |  8KB  |  206 lines

  1. /* rexx */
  2.  '@echo off'
  3.  null = '1>/dev/nul 2>&1';
  4.  
  5.  call rxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  6.  call SysLoadFuncs
  7.  
  8.  call SysCls;
  9.  call SetColor White;
  10.  say center("───────┤ C O N S O L E ├───────", 78);
  11.  call SetColor LCyan;
  12.  say center("     installation program      ", 78);
  13.  call SetColor LBlue;
  14.  say center("───────────────────────────────", 78);
  15.  
  16.  say "";
  17.  call SetColor Yellow;
  18.  say center("WARNING", 78);
  19.  call SetColor LGreen;
  20.  say "";
  21.  say center("This program is free software; you can redistribute it and/or modify", 78);
  22.  say center("it under the terms of the GNU General Public License as published by", 78);
  23.  say center("the Free Software Foundation; either version 2 of the License, or", 78);
  24.  say center("(at your option) any later version.", 78);
  25.  say "";
  26.  say center("This program is distributed in the hope that it will be useful,", 78);
  27.  say center("but WITHOUT ANY WARRANTY; without even the implied warranty of", 78);
  28.  say center("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the", 78);
  29.  say center("GNU General Public License for more details.", 78);
  30.  say "";
  31.  say center("You should have received a copy of the GNU General Public License", 78);
  32.  say center("along with this program; if not, write to the Free Software", 78);
  33.  say center("Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA", 78);
  34.  say "";
  35.  call SetColor Red;
  36.  say center("Press ENTER if you agree, any other key if you don't", 78);
  37.  if SysGetKey('NOECHO') <> d2c(13)
  38.   then do
  39.     call SysCls;
  40.     call SysCurPos 12,1;
  41.     call SetColor LRed;
  42.     say center("-=Too bad for you=-", 78);
  43.         exit;
  44.        end;
  45.  
  46.  call SetColor Yellow
  47.  if stream('eConsole.exe', 'C', 'QUERY EXISTS') <> ''
  48.   then do
  49.         call charout ,'please wait a bit ...'
  50.         'eConsole.exe 'null' <install.cmd';
  51.         if (rc = 0)
  52.          then do
  53.                'del sConsole.exe sCWRP.exe 'null;
  54.                'ren eConsole.exe Console.exe 'null;
  55.                'ren eCWRP.exe CWRP.exe 'null;
  56.               end;
  57.          else do
  58.                'del eConsole.exe eCWRP.exe 'null;
  59.                'ren sConsole.exe Console.exe 'null;
  60.                'ren sCWRP.exe CWRP.exe 'null;
  61.               end;
  62.         say ' ok';
  63.        end;
  64.  
  65.  call SetColor Green
  66.  say "Please enter the destination directory for program, ex: C:\OS2\APPS:"
  67.  call SetColor LGreen
  68.  do until (destDir <> '')
  69.   pull destDir
  70.  end;
  71.  if (length(destDir) > 3) & (pos(right(destDir, 1), "\/") > 0)
  72.   then destDir = left(destDir, length(DestDir) - 1);
  73.  do while stream(destDir,"c","query datetime") = ""
  74.   QueryCreate = Ask("The directory you specified does not exist. Create it? (Y/N)", "YN")
  75.   select
  76.    when QueryCreate = "Y"
  77.     then 'mkDir 'destDir' 1>nul 2>nul'
  78.    otherwise
  79.     say "Aborting..."
  80.     exit
  81.   end
  82.  end
  83.  curDir = directory();
  84.  destDir = directory(destDir);
  85.  call directory curDir;
  86.  
  87.  if Pos(translate(destDir), translate(value('PATH',,'OS2ENVIRONMENT'))) = 0
  88.   then do
  89.         call SetColor LRed;
  90.         say 'You should put "'destDir'" in the PATH variable of your CONFIG.SYS';
  91.         say 'and then reboot';
  92.        end;
  93.  
  94.  call CopyFile 'Console.exe', '';
  95.  call CopyFile 'CWRP.exe', '';
  96.  
  97.  QueryFolder = Ask("Do you want a folder with CONSOLE usage examples? (Y/N)", "YN");
  98.  if (QueryFolder = "Y")
  99.   then do
  100.         rc = SysCreateObject('WPFolder', 'Console', '<WP_DESKTOP>', ,
  101.              'OBJECTID=<CONSOLE_FOLDER>;CCVIEW=NO;'||,
  102.              'ICONVIEWPOS=30,50,50,40;ICONVIEW=FLOWED;', 'U');
  103.         rc = SysSetObjectData('<CONSOLE_FOLDER>', 'OPEN=DEFAULT');
  104.         rc = SysCreateObject('WPProgram', 'Weak title', '<CONSOLE_FOLDER>', ,
  105.              'EXENAME='destDir'\CONSOLE.EXE;MINIMIZED=YES;PARAMETERS=-on 'destDir'\CONSOLE.EXE -t"Top-level title" * /k 'destDir'\CONSOLE.EXE -t"Weak title -- type {exit}" *', 'U');
  106.         rc = SysCreateObject('WPProgram', 'Sticky title', '<CONSOLE_FOLDER>', ,
  107.              'EXENAME='destDir'\CONSOLE.EXE;MINIMIZED=YES;PARAMETERS=-on -t"Sticky title"', 'U');
  108.         rc = SysCreateObject('WPProgram', 'Scrolling window', '<CONSOLE_FOLDER>', ,
  109.              'EXENAME='destDir'\CONSOLE.EXE;PARAMETERS=-t"Scrolling window" -p,,200,100 *', 'U');
  110.         rc = SysCreateObject('WPProgram', 'Background', '<CONSOLE_FOLDER>', ,
  111.              'EXENAME='destDir'\CONSOLE.EXE;MINIMIZED=YES;PARAMETERS=-on -ob -p0,0', 'U');
  112.         rc = SysCreateObject('WPProgram', 'Flashing', '<CONSOLE_FOLDER>', ,
  113.              'EXENAME='destDir'\CONSOLE.EXE;PARAMETERS=-of *', 'U');
  114.         rc = SysCreateObject('WPProgram', 'Thick border', '<CONSOLE_FOLDER>', ,
  115.              'EXENAME='destDir'\CONSOLE.EXE;PARAMETERS=-b10,10 *', 'U');
  116.         rc = SysCreateObject('WPProgram', '40x40 with 8x8 font', '<CONSOLE_FOLDER>', ,
  117.              'EXENAME='destDir'\CONSOLE.EXE;MINIMIZED=YES;PARAMETERS=-on -s40,40 -f8,8', 'U');
  118.         rc = SysCreateObject('WPProgram', '80x33 with 10x6 font', '<CONSOLE_FOLDER>', ,
  119.              'EXENAME='destDir'\CONSOLE.EXE;PARAMETERS=-s80,33 -f10,6 *', 'U');
  120.         rc = SysCreateObject('WPProgram', 'Alternate OS/2 window[640x480]', '<CONSOLE_FOLDER>', ,
  121.              'EXENAME='destDir'\CONSOLE.EXE;MINIMIZED=YES;PARAMETERS=-on -p80,30 -s80,40 -f10,6 *', 'U');
  122.         rc = SysCreateObject('WPProgram', 'Alternate OS/2 window[800x600]', '<CONSOLE_FOLDER>', ,
  123.              'EXENAME='destDir'\CONSOLE.EXE;MINIMIZED=YES;PARAMETERS=-on -p80,40 -s80,33 -f14,8 *', 'U');
  124.         rc = SysCreateObject('WPProgram', 'Alternate OS/2 window[1024x768]', '<CONSOLE_FOLDER>', ,
  125.              'EXENAME='destDir'\CONSOLE.EXE;MINIMIZED=YES;PARAMETERS=-on -p360,104 -s80,40 -f14,8 *', 'U');
  126.        end;
  127.  
  128.  say ""
  129.  if Ask("Do you wish to read the documentation now? (Y/N)", "YN") = "Y"
  130.   then 'view doc\Console.inf';
  131.  say ""
  132.  call SetColor Yellow;
  133.  say "The directory doc\ contains documentation files in both"
  134.  say "INF and HTML formats. Install program did not copied them,"
  135.  say "you should do it itself if you want them."
  136.  call SetColor LGreen;
  137.  say "You also can go to examples\ directory to see some"
  138.  say "sample Console usage REXX scripts"
  139. exit 0;
  140.  
  141. CopyFile:
  142.  parse arg fName dPath
  143.  call SetColor Cyan
  144.  say "Copying "fName" -> "destDir||dPath"\"fName
  145.  'copy 'fName destDir||dPath' 1>nul 2>nul'
  146. return;
  147.  
  148. Ask:
  149.  parse arg Question,Reply;
  150.  call SetColor Green
  151.  rc = charOut(, Question)
  152.  call SetColor LGreen
  153.  do until Pos(Answer, Reply) \= 0
  154.   KeyIn = SysGetKey("noecho")
  155.   parse upper var KeyIn Answer
  156.  end
  157.  say Answer;
  158. return Answer;
  159.  
  160. SetColor:
  161.  procedure expose break;
  162.  arg Col;
  163.  Col = ColorNo(Col);
  164.  
  165.  if Col = -1 then return -1;
  166.  if Col > 7
  167.   then Col = '1;3'Col-8;
  168.   else Col = '0;3'Col;
  169.  call charOut ,d2c(27)'['Col'm';
  170. return 0;
  171.  
  172. ColorNo:
  173.  procedure expose break;
  174.  arg ColName;
  175.  if Substr(ColName, 1, 1) = 'L'
  176.   then do
  177.         ColName = right(ColName, length(ColName) - 1);
  178.         Light = 8;
  179.        end
  180.   else Light = 0;
  181.  select
  182.   when Abbrev('BLACK', ColName, 3)
  183.    then return Light + 0;
  184.   when Abbrev('BLUE', ColName, 3)
  185.    then return Light + 4;
  186.   when Abbrev('GREEN', ColName, 3)
  187.    then return Light + 2;
  188.   when Abbrev('CYAN', ColName, 3)
  189.    then return Light + 6;
  190.   when Abbrev('RED', ColName, 3)
  191.    then return Light + 1;
  192.   when Abbrev('MAGENTA', ColName, 3)
  193.    then return Light + 5;
  194.   when Abbrev('BROWN', ColName, 3)
  195.    then return Light + 3;
  196.   when Abbrev('GRAY', ColName, 3)
  197.    then return Light + 7;
  198.   when Abbrev('DGRAY', ColName, 3)
  199.    then return 8;
  200.   when Abbrev('YELLOW', ColName, 3)
  201.    then return 11;
  202.   when Abbrev('WHITE', ColName, 3)
  203.    then return 15;
  204.  end;
  205. return -1;
  206.