Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
PROCEDURE StripChr
PARAMETER cFile, cChr
DO CASE
CASE TYPE("cChr")<>"C" .OR. LEN(cChr)=0
? "Search characters not specified correctly."
CASE TYPE("cFile")<>"C" .OR. LEN(cFile)=0
? "File name not specified correctly."
CASE .NOT. FILE(cFile)
? "File not found."
OTHERWISE
PRIVATE cMatch, nLen, cDesc, nHandle, fEnd, fChr, xVal
cMatch=cChr
IF UPPER(cMatch)="EOF"
cMatch=CHR(26)
ENDIF
IF UPPER(cMatch)="CRLF"
cMatch=CHR(13)+CHR(10)
ENDIF
nLen=LEN(cMatch)
cDesc="Character"+IIF(nLen=1,"","s")
nHandle=FOPEN(cFile,"RW")
IF nHandle=0
? cFile+" could not be opened low level."
ELSE
? "Processing "+cFile+"..."
fEnd=FSEEK(nHandle,0,2) && this is EOF
xVal=FSEEK(nHandle,0-nLen,1) && move to char(s)
fChr=FREAD(nHandle,nLen) && get character(s)
IF fChr=cMatch
? cDesc+" found at end of file. Removing..."
fEnd=FSEEK(nHandle,0-nLen,1) && move to char(s)
xVal=FWRITE(nHandle,"",0) && write nothing
ELSE
? cDesc+" not found at end of file. No action taken."
ENDIF
xVal=FCLOSE(nHandle) && truncates file after writing nothing
? cFile+" has been closed."
ENDIF
ENDCASE
RETURN