Newbie question -- URL Access Error

Hi there,

I feel somewhat ashamed that I can’t seem to figure out what is wrong with this simple script – so, perhaps someone has an idea? I’m getting an error “URL Access Scripting got an error: Folder some object wasn’t found” and highlights the
download target_URL to file … line of my script. Any help would be greatly appreciated.

set the today_date to (“NP_” & (current date) & “.puz”)
set the target_URL to “http://www.networdcross.com/cgi-bin/nwserve/today.puz
set the destination_file to ((path to desktop as string) & today_date)

tell application “URL Access Scripting”
download target_URL to file destination_file replacing yes
end tell

tell application “Finder” to open alias destination_file

I would guess that the colons in the time are causing the error. Colons shouldn’t be used in file/folder names because they are used in paths.

You should let the CGI work with the URL Access Scripting by getting the file first, then renaming the file once on the desktop.

change the destination variable to this:

set the destination_file to ((path to desktop as string) & “today.puz”)

Before naming the file with the date, follow the suggestion about the colons with the name.
set name of destination_file to today_date
Also set the today_date variable to a string, else the script will fail.

Here is my suggested script changes:

get the month of (the current date) --as integer
set aMonth to result
set the list_of_months to {January, February, March, April, ¬
	May, June, July, August, September, October, November, December}
repeat with i from 1 to 12
	if item i of the list_of_months is the aMonth then
		set the numeric_month to i
		exit repeat
	end if
end repeat
set aMonth to numeric_month as text
get day of (current date) as integer
set aDay to result
get year of (current date) as integer
set aYear to result
set aDate to aMonth & "/" & aDay & "/" & aYear as text
--display dialog aDate

set the today_date to ("NP_" & (aDate) & ".puz") as string
set the target_URL to "http://www.networdcross.com/cgi-bin/nwserve/today.puz"
set the destination_file to ((path to desktop as string) & "today.puz") as string
tell application "URL Access Scripting"
	download target_URL to file destination_file replacing yes
end tell

tell application "Finder" to set name of alias destination_file to today_date as text
--tell application "Finder" to open alias destination_file