Re: Search a file question - Mac OS 9
Re: Search a file question - Mac OS 9
- Subject: Re: Search a file question - Mac OS 9
- From: Charles Heizer <email@hidden>
- Date: Tue, 17 Sep 2002 16:10:54 -0700
Hi Gang,
thanks, for all the help. My log files can be up to 3MB, so I do have a
32k issue. Because of these issues I have moved a way from using
AppleScript and I'm writing a small RealBasic app to do this, and since
RealBasic has regular expression, I can use a similar statement to what
Bill provided.
Thanks again to all that helped me out on this.
- Charles
On Tuesday, September 17, 2002, at 01:55 PM, Arthur J. Knapp wrote:
Date: Tue, 17 Sep 2002 10:24:46 -0700
Subject: Search a file question - Mac OS 9
From: Charles Heizer <email@hidden>
I'm having some trouble getting a script to read a log file to work
properly.
I'm trying to find any line that that contains "RC [someerror]" for
example. Then write that line with it's line number out to a new text
file. The thing is I don't want it to grab the lines that contain "RC
[0]" because a return code of zero means there were no problems.
Charles, is this a fairly small log file, somewhere under 32k? If it
is, we can really do all of our work as basic string manipulations:
set log_content to read (choose file) -- for debugging
set error_lines to {} --> collect
repeat with i from 1 to count paragraphs in log_content
if ( log_content's paragraph i contains "RC [" ) then
if ( log_content's paragraph i does not contain "RC [0]" )
then
set error_lines's end to log_content's paragraph i
end
end
end
set error_content to error_lines as string
set new_file to open for access file "MacHD:My Log" with write
permission
write error_content to new_file
close access new_file
Most of the time, it really isn't worth it to use line by line file
reading. Just give your script application a reasonable amount of
memory and read the entire file you are parsing into a variable.
{ Arthur J. Knapp, of <http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m
}
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.