• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
if the document named (.........) exists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: if the document named (.........) exists
      • From: Christopher Stone <email@hidden>
    • Re: if the document named (.........) exists
      • From: "Stockly, Ed" <email@hidden>
    • Re: if the document named (.........) exists
      • From: Steve Mills <email@hidden>
  • Prev by Date: Re: Xcode + ApplescriptOBC + Button + GUI -> Access to Numbers
  • Next by Date: Re: if the document named (.........) exists
  • Previous by thread: Re: Xcode + ApplescriptOBC + Button + GUI -> Access to Numbers
  • Next by thread: Re: if the document named (.........) exists
  • Index(es):
    • Date
    • Thread