Hi,
I have a program that I am writing where I read in an ASCII file and search each line to see if it has any special control characters in it. What I would like to do is, when I find a line that has one of these special control characters (ex. FF) in it, I want to update the line right then and write back to it. The following code read the file and writes back to it. It writes back to it fine but, it also put an extra line after the line I just wrote. I can't tell if it is an extra line or just the line that it wrote plus with extra spaces wrapping with it.
Here is the code
if index(intext,'0C'X) then do;
put " ** ALERT!! - special character found.";
pos = index(intext,'0C'X);
put " Position of character is: " pos;
/* Copy the problem file to save it first. */
command='cp '||"&chkdir"||f2r||' '||fil2name;
call system(command);
/* Remove this special character */
txt2 = compress(intext,'0C'X);
/* Output the corrected line back to the file */
txt2 = compbl(txt2);
FILE dummy; /* write back to the file. */
newln = txt2;
newln = strip(newln);
PUT @1 newln;
FILE log;
end;
Thanks if anyone can give me help here.
HunterN