if the document named (.........) exists
if the document named (.........) exists
- Subject: if the document named (.........) exists
- From: William Seabrook <email@hidden>
- Date: Wed, 08 May 2019 21:38:50 +0000
- Thread-topic: if the document named (.........) exists
Here is an extract from a script to request the load a web page in Safari, and
wait until it is complete before continuing:
...........
set html to
"https://archives.newyorker.com/rvimageserver/Conde Nast/New Yorker/" &
thisyear & "/" & pagenumber
tell application "Safari"
if not (exists document 1) then reopen
(*
load URL
*)
tell current tab of window 1 to set URL to html
set fname to pagenumber & " 2,048×2,797 pixels"
set ename to pagenumber & " 2,048×2,881 pixels"
set aname to pagenumber & " 2,048×2,832 pixels"
set bname to pagenumber & " 2,048×2,917 pixels"
set cname to pagenumber & " 2,048×2,867 pixels"
set dname to pagenumber & " 2,048×2,953 pixels"
set ename to pagenumber & " 2,048×2,881 pixels"
set fname to pagenumber & " 2,048×2,797 pixels"
(*
wait for page to load
*)
repeat while myexit = "false"
delay 2
if the document named (aname) exists then
set myexit to "true"
end if
if the document named (bname) exists then
set myexit to "true"
end if
if the document named (cname) exists then
set myexit to "true"
end if
if the document named (dname) exists then
set myexit to "true"
end if
if the document named (ename) exists then
set myexit to "true"
end if
if the document named (fname) exists then
set myexit to "true"
end if
end repeat
...........
As the actual name of the document Safari will have loaded varies, I have had
to compare against a number of possibilities. Is it possible to use a
wildcard, a regular expression, or use a comparison of the form startingwith
and/or containing, so I only need to check for "2,048×"?
Thank you
Bill Seabrook
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden