Your best friend for file transfer.

Fetch application logoFetch

repeat doesn't seem to count transfer windows correctly. (5 posts)

  • Started 13 years ago by Gil
  • Latest reply 13 years ago from Jim Matthews
  • Gil Member

    The following snippet:

    log "count of transfer windows=" & (count of transfer windows) --> 2
    repeat with w in transfer windows
    log "id of w=" & id of w
    log "w is ourTwindow? = " & ¬
    ((id of w) is (id of ourTwindow))
    end repeat

    Produces this log:
    count of transfer windows=2
    id of w=319466064
    w is ourTwindow? = false
    id of w=18810720
    w is ourTwindow? = true

    And then gets this error:
    Can't make id of item 3 of every «class cFWA» of
    application "Fetch" into type Unicode text."

    Item 3? There are only two transfer windows (count of transfer windows=2).
    Why is Fetch trying to access a third transfer window?
    Could this be a bug?

    --Gil

    Posted 13 years ago #

  • Jim Matthews Administrator

    There is a bug, but I think it's in AppleScript. You can see a similar problem with this script, which tries to walk through Finder windows and finds an infinite number:

    tell application "Finder"
    display dialog "There are " & (count every window) & " Finder windows"
    set counter to 0
    repeat with w in windows
    set counter to counter + 1
    display dialog "Window #" & counter
    end repeat
    counter
    end tell

    To work around this problem, I would replace the line:

    repeat with w in transfer windows

    with these two lines:

    set tws to transfer windows
    repeat with w in tws

    That should work.

    Thanks for reporting this -- I hadn't seen it before.

    Jim Matthews
    Fetch Softworks

    Posted 13 years ago #

  • Gil Member

    Thanks, Jim--

    That worked just fine!

    Unless you've already done so, I will check to be sure that Apple knows about this.

    Thanks again for the help.

    --Gil

    Posted 13 years ago #

  • Gil Member

    Hi, Jim--

    Another way to get it to work, which may provide a clue as to why mine doesn't:

    repeat with w in (get Finder windows)

    Thanks to Brian Christmas for this one.

    --Gil

    Posted 13 years ago #

  • Jim Matthews Administrator

    Hi Gil,

    Thanks for sharing that. AppleScript's behavior is sometimes very mysterious, to me anyway.

    Jim Matthews
    Fetch Softworks

    Posted 13 years ago #

Reply

  • Or nickname, if you prefer.
  • This will be kept confidential.
  • This is to ensure that you’re a person, not a spambot.