REM This program can change one string to another REM in any text file, such a an OPL source code. REM I used it to shorten the variable names in my REM program Letsshop in order to save memory. REM This program keeps repeating the search through REM the file until it does a complete scan without REM finding any strings to replace - not efficient, REM but it works! PROC Change V: GLOBAL ret%,fname$(128),fname2$(128),address%,handle%,mode%,k%,a1$(100),a2$(100),a3$(100),a4$(100),file1$(128),file2$(128),x%,c% GLOBAL z%,txt$(255) Fname$="\OPL\*.opl" File1$="\OPL\" File2$="\OPL\" dINIT "File to change" dFILE fname$,"Open File",64 dFILE File1$,"Save to File",65 dFILE File2$,"Temp File",65 IF DIALOG=0 STOP ENDIF fname2$=File1$ BUSY "Changing Vs" DO z%=0 doit: IF fname2$=File2$ fname2$=File1$ fname$=File2$ ELSE fname2$=File2$ fname$=File1$ ENDIF REM the following number tells you the REM number of replacements made on the REM last scan PRINT z% UNTIL z%=0 BUSY OFF DELETE File2$ ENDP PROC doit: LOPEN fname2$ mode%=$0400 OR $0020 ret%=IOOPEN(handle%,fName$,mode%) IF ret%<0 ShowErr: (ret%) RETURN ENDIF address%=ADDR(txt$) WHILE 1 k%=KEY IF k% IF k%=27 RETURN ELSEIF GET=27 RETURN ENDIF ENDIF ret%=IOREAD (handle%,address%+1,255) IF ret%<0 IF ret%<>-36 showErr:(ret%) ENDIF BREAK ELSE POKEB address%,ret% REM Replace the following Variables with the ones you want to hunt out and REM replace. You can have as many ELSEIF statements as you want. IF LOC(txt$,"Var1%")<>0 replace:("Var1%","Rep1%") REM var1%=The string you want to replace REM rep1%=The string to replace var1% with ELSEIF LOC(txt$,"Var2%")<>0 replace:("Var2%","Rep2%") ELSE LPRINT txt$ ENDIF ENDIF ENDWH ret%=IOCLOSE(handle%) IF ret% showerr:(ret%) ENDIF LCLOSE ENDP PROC replace:(a$,b$) c%=LEN(a$) LPRINT LEFT$(txt$,(LOC(txt$,a$))-1); LPRINT b$; LPRINT MID$(txt$,LOC(txt$,a$)+c%,LEN(txt$)-LOC(txt$,a$)+c%) z%=z%+1 ENDP PROC showErr:(val%) PRINT "Error",val%,err$(val%) GET ENDP