Removing Lines from A File...

Hello,

I am grabbing the content of an EPS (Encapsulated PostScript) file from a remote system and then saving that data in a file on my local system for comparison. I want to remove certain lines from the file that change every time I save the file off.

My script says:

repeat with each line in localFile
if the value of it contains "%%Title:" then delete it
end repeat

I get:

Syntax Error at line 1:  - can't understand "%" at or near character 1

Any suggestions?

repeat with each line in localFile
if it contains “%%Title:” then delete it
end repeat

Removing ‘the value of’ - does that work for you?
-edj

I’m guessing edj is right – the error message you’re getting looks like it comes from trying to use value() to evaluate that string.

Once you resolve that little issue, if you want to actually delete lines from the file you’ll need to iterate over the lines “by reference”. So your code should end up looking something like this:

repeat with each line in localFile by reference
  if it contains "%%Title:" then delete it 
end repeat 

I’ll try by reference.

If I remove the call to value, it got rid of the synax error, but it never runs through the loop. It treats the file as one object.

Without using “by reference” your code won’t really do anything. However, if it’s really treating the whole file as a single line, that suggests that your EPS file is using different line endings. The standard line delimiter in SenseTalk is a LineFeed character (ASCII 10). If the file actually uses a CarriageReturn between lines, you could do this:

repeat with each line delimited by CR in localFile by reference 
  if it contains "%%Title:" then delete it 
end repeat

CR and CRLF are predefined variables you can use in this way when dealing with files created on other operating systems.