Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another load movie question



How about this ? 


set urlText to 
"file://localhost/Users/maro/Documents/Develop/%23randomMovieShuffler/rms_wo
rld.txt"
set b to urlToPath(urlText) of me
set c to b as alias
set d to POSIX path of c --POSIX path


on urlToPath(aText)
    if aText does not start with "file://localhost" then
        return ""
    else
        set aText to (characters 17 thru -1 of aText) as text
    end if
    tell application "Finder"
        set aName to name of startup disk
    end tell
    
    set a to decode_text(aText) of me
    set b to replace_chars(a, "/", ":") of me
    return aName & b
end urlToPath



-----------------------Apple's sample Sub routines


on replace_chars(this_text, search_string, replacement_string)
    set AppleScript's text item delimiters to the search_string
    set the item_list to every text item of this_text
    set AppleScript's text item delimiters to the replacement_string
    set this_text to the item_list as string
    set AppleScript's text item delimiters to ""
    return this_text
end replace_chars

-- this sub-routine is used to decode a three-character hex string
on decode_chars(these_chars)
    copy these_chars to {indentifying_char, multiplier_char, remainder_char}
    set the hex_list to "123456789ABCDEF"
    if the multiplier_char is in "ABCDEF" then
        set the multiplier_amt to the offset of the multiplier_char in the
hex_list
    else
        set the multiplier_amt to the multiplier_char as integer
    end if
    if the remainder_char is in "ABCDEF" then
        set the remainder_amt to the offset of the remainder_char in the
hex_list
    else
        set the remainder_amt to the remainder_char as integer
    end if
    set the ASCII_num to (multiplier_amt * 16) + remainder_amt
    return (ASCII character ASCII_num)
end decode_chars


-- this sub-routine is used to decode text strings
on decode_text(this_text)
    set flag_A to false
    set flag_B to false
    set temp_char to ""
    set the character_list to {}
    repeat with this_char in this_text
        set this_char to the contents of this_char
        if this_char is "%" then
            set flag_A to true
        else if flag_A is true then
            set the temp_char to this_char
            set flag_A to false
            set flag_B to true
        else if flag_B is true then
            set the end of the character_list to my decode_chars(("%" &
temp_char & this_char) as string)
            set the temp_char to ""
            set flag_A to false
            set flag_B to false
        else
            set the end of the character_list to this_char
        end if
    end repeat
    return the character_list as string
end decode_text



On 05.3.12 9:13 PM, "Kiel" <email@hidden> wrote:

> Hi all,
> 
> If I got an URL as file path, how can I make this path either into a
> posix path or load it directly?
> I have tried
> call method "initWithURL:byReference:" of object "NSMovie"
> But I can't make it work
> 
> Andreas
> 
> 
> Andreas Kiel
> 
> Spherico
> Nelkenstr. 25
> D-76185 Karlsruhe
> Tel.: +49 (0)721 183 9753
> eFax: +1 650 897 8094
> eMail: email@hidden
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-studio mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/applescript-studio/email@hidden
> 
> This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >Another load movie question (From: Kiel <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.