home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cenvi23.zip
/
ENVIEDIT.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-08-15
|
1KB
|
48 lines
@echo off
REM ***********************************************************
REM *** EnviEdit.cmd - Edit the environment with EPM editor ***
REM *** ver.1 ***
REM ***********************************************************
SET > ~ENVEDT~.CMD
CEnvi2 %0.cmd
GOTO CENVI_EXIT
// read all the environment variables to initially clear them
fp = fopen("~ENVEDT~.CMD","rt");
oldvcount = 0;
while ( line = fgets(fp) ) {
if ( line[0] && (Equal=strchr(line,'=')) ) {
Equal[0] = 0;
oldvarlist[oldvcount++] = line;
}
}
fclose(fp);
// let the standard editor edit this file
system("SESSION /F /PM /WAIT EPM.EXE ~ENVEDT~.CMD");
// read in the newly-edited file
fp = fopen("~ENVEDT~.CMD","rt");
newvcount = 0;
while ( line = fgets(fp) ) {
if ( line[0] && (Equal=strchr(line,'=')) ) {
newvarlist[newvcount++] = line;
}
}
fclose(fp);
// add old lines to remove old variables
fp = fopen("~ENVEDT~.CMD","wt");
fprintf(fp,"@echo off\n");
for ( i = 0; i < oldvcount; i++ )
fprintf(fp,"SET %s=\n",oldvarlist[i]);
// add lines to set new variables
for ( i = 0; i < newvcount; i++ )
fprintf(fp,"SET %s",newvarlist[i]);
fclose(fp);
:CENVI_EXIT
CALL ~ENVEDT~.CMD
DEL ~ENVEDT~.CMD /F