Re: OSX Coding Help
Re: OSX Coding Help
- Subject: Re: OSX Coding Help
- From: Andrew Oliver <email@hidden>
- Date: Mon, 30 Jun 2003 20:30:55 -0700
The short answer is that the line:
>
set eof of "OSX:List Addresses:Fishads Addresses" to 0
is trying to set the EOF of a string. Bzzzzt.
As you've already seen, prepending file before the file name solves the
issue, although there's a somewhat neater solution:
>
set the FishadsAddressFile to open for access "OSX:List Addresses:Fishads
Addresses" with write permission
At this point 'FishadsAddressFile' is an AppleScript object that references
the file, so you can now:
set EOF FishadsAddressFile to 0
This guarantees you're targeting the correct file (and saves typing)
Andrew
:)
and that follows the reference and resets the file.
On 6/30/03 2:23 PM, "Jeff Grossman" <email@hidden> wrote:
>
on 6/27/03 10:13 AM, Andrew Oliver at email@hidden wrote:
>
>
> On 6/27/03 7:55 AM, "Jeff Grossman" <email@hidden> wrote:
>
>
>
>> I have the following script which will delete some files, if they exist, and
>
>> then export some address lists from LetterRip Pro. I want the script to run
>
>> from cron as an application. If I remove the beginning part which deletes
>
>> the existing files the script will run fine via cron. If I add back in the
>
>> part about deleting files, the script will not run via cron. Is it not
>
>> possible to do what I want with Applescript and cron?
>
> [snip[]
>
>
>
> There's actually no need to delete the files at all.
>
>
>
> When you 'open for access' the files to write out the new data, just 'set
>
> EOF' of each file to 0 before you start writing data. That will effectively
>
> clear the existing file before any new data is written and solves your
>
> problem.
>
>
Okay, I tried your idea, but it does not seem to be working for me. When I
>
run the script, I get a duplicate file error. Here is a copy of the script:
>
>
set the FishadsAddressFile to open for access "OSX:List Addresses:Fishads
>
Addresses" with write permission
>
set eof of "OSX:List Addresses:Fishads Addresses" to 0
>
tell application "LetterRip_Server"
>
set a_list to subscriber list "Fishads"
>
set theCount to count of subscribers of a_list
>
>
set cur to 1
>
repeat until cur > theCount
>
set theSub to subscriber cur of a_list
>
set theName to name of theSub
>
set theAddress to email address of theSub
>
set cur to cur + 1
>
my WriteFile(FishadsAddressFile, theName, theAddress)
>
end repeat
>
end tell
>
close access FishadsAddressFile
>
>
set the HuntadsAddressFile to open for access "OSX:List Addresses:Huntads
>
Addresses" with write permission
>
set eof of "OSX:List Addresses:Huntads Addresses" to 0
>
tell application "LetterRip_Server"
>
set a_list to subscriber list "Huntads"
>
set theCount to count of subscribers of a_list
>
>
set cur to 1
>
repeat until cur > theCount
>
set theSub to subscriber cur of a_list
>
set theName to name of theSub
>
set theAddress to email address of theSub
>
set cur to cur + 1
>
my WriteFile(HuntadsAddressFile, theName, theAddress)
>
end repeat
>
end tell
>
close access HuntadsAddressFile
>
>
set the FishReportsAddressFile to open for access "OSX:List
>
Addresses:FishReports Addresses" with write permission
>
set eof of "OSX:List Addresses:FishReports Addresses" to 0
>
tell application "LetterRip_Server"
>
set a_list to subscriber list "Fish Reports"
>
set theCount to count of subscribers of a_list
>
>
set cur to 1
>
repeat until cur > theCount
>
set theSub to subscriber cur of a_list
>
set theName to name of theSub
>
set theAddress to email address of theSub
>
set cur to cur + 1
>
my WriteFile(FishReportsAddressFile, theName, theAddress)
>
end repeat
>
end tell
>
close access FishReportsAddressFile
>
>
set the HuntReportsAddressFile to open for access "OSX:List
>
Addresses:HuntReports Addresses" with write permission
>
set eof of "OSX:List Addresses:HuntReports Addresses" to 0
>
tell application "LetterRip_Server"
>
set a_list to subscriber list "Hunt Reports"
>
set theCount to count of subscribers of a_list
>
>
set cur to 1
>
repeat until cur > theCount
>
set theSub to subscriber cur of a_list
>
set theName to name of theSub
>
set theAddress to email address of theSub
>
set cur to cur + 1
>
my WriteFile(HuntReportsAddressFile, theName, theAddress)
>
end repeat
>
end tell
>
close access HuntReportsAddressFile
>
>
set the NewsAddressFile to open for access "OSX:List Addresses:News
>
Addresses" with write permission
>
set eof of "OSX:List Addresses:News Addresses" to 0
>
tell application "LetterRip_Server"
>
set a_list to subscriber list "News"
>
set theCount to count of subscribers of a_list
>
>
set cur to 1
>
repeat until cur > theCount
>
set theSub to subscriber cur of a_list
>
set theName to name of theSub
>
set theAddress to email address of theSub
>
set cur to cur + 1
>
my WriteFile(NewsAddressFile, theName, theAddress)
>
end repeat
>
end tell
>
close access NewsAddressFile
>
>
to WriteFile(myFile, aName, anAddress)
>
write aName & tab & anAddress & return to myFile
>
end WriteFile
>
>
Thanks,
>
Jeff
_______________________________________________
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.