Professional Web Applications Themes

buddy rename - Macromedia Director Lingo

hi, i need help on renaming a file using buddy api. ** the process*** selected a graphic that repesents a file on the desktop the name is placed into the field named 'txtfile' the rename buttons is pressed the field become editiable rename the file --press return to excute the renaming it then should check if the name exsists, if so add copy to the end of the name ** problem ** its not picking up the enter key, instead of excuting the renaming, its just placing a cariage return to the next line of the field. how do i ...

  1. #1

    Default buddy rename

    hi,
    i need help on renaming a file using buddy api.

    ** the process***
    selected a graphic that repesents a file on the desktop
    the name is placed into the field named 'txtfile'
    the rename buttons is pressed
    the field become editiable
    rename the file
    --press return to excute the renaming
    it then should check if the name exsists, if so add copy to the end of the
    name



    ** problem **
    its not picking up the enter key, instead of excuting the renaming, its just
    placing a cariage return to the next line of the field.

    how do i do this?

    cheers
    lee


    **note - pdl this a variable that holds the filename
    ----------------
    on RenameME

    delim = the last char of the moviePath

    tFilePath = the moviePath & "Tank\" & pdl

    member("txtfile").editable = TRUE

    end

    on keyDown

    fieldname = member("txtfile").text


    OK = baRenameFile(pdl, fieldname )

    case the key of
    RETURN, ENTER, BACKSPACE, TAB: pass
    end case
    end if
    -- member("txtfile").editable = false

    end
    -------------------------


    LeeD Guest

  2. #2

    Default Re: buddy rename

    I think it's :

    | RETURN, ENTER, BACKSPACE, TAB: nothing -- (instead of pass)

    --
    ----------------
    -- Ned
    ----------------------------------------
    Bien faire et laisser braire
    ----------------------------------------
    "LeeD" <Baronyomo.com> a écrit dans le message de
    news:bhfml3$fni$1forums.macromedia.com...
    | hi,
    | i need help on renaming a file using buddy api.
    |
    | ** the process***
    | selected a graphic that repesents a file on the desktop
    | the name is placed into the field named 'txtfile'
    | the rename buttons is pressed
    | the field become editiable
    | rename the file
    | --press return to excute the renaming
    | it then should check if the name exsists, if so add copy to the end of the
    | name
    |
    |
    |
    | ** problem **
    | its not picking up the enter key, instead of excuting the renaming, its
    just
    | placing a cariage return to the next line of the field.
    |
    | how do i do this?
    |
    | cheers
    | lee
    |
    |
    | **note - pdl this a variable that holds the filename
    | ----------------
    | on RenameME
    |
    | delim = the last char of the moviePath
    |
    | tFilePath = the moviePath & "Tank\" & pdl
    |
    | member("txtfile").editable = TRUE
    |
    | end
    |
    | on keyDown
    |
    | fieldname = member("txtfile").text
    |
    |
    | OK = baRenameFile(pdl, fieldname )
    |
    | case the key of
    | RETURN, ENTER, BACKSPACE, TAB: pass
    | end case
    | end if
    | -- member("txtfile").editable = false
    |
    | end
    | -------------------------
    |
    |


    Ned Guest

  3. #3

    Default Re: buddy rename

    On 14 Aug 2003, "LeeD" <Baronyomo.com> wrote:
    > the name is placed into the field named 'txtfile'
    > the rename buttons is pressed
    > the field become editiable
    > rename the file
    > --press return to excute the renaming
    > it then should check if the name exsists, if so add copy to the end of
    > the name
    >
    1. You'll need to supply the full path to the destination name as well as
    the source name.

    newName = the moviePath & "Tank\" &fieldName

    2. You haven't checked whether the new file name exists. You'll probably
    find it easier to prepend rather than append "copy" to the filename (as
    Photoshop does) so you don't have to extract any file extensions.

    if baFileExists(newName) then
    newName = tFilePath &"Tank\Copy of" &&fieldName
    end if

    If you really want to append "copy" to the filename, you'll want to
    extract the extension (if any) before appending, then tack the extension
    back on. Setting the itemDelimiter to "." and getting the last item of
    the string should get you started.

    3. You'll need to determine success/fail by checking the OK variable
    returned by baRenameFile().

    OK = baRenameFile(pdl, newName)
    if NOT OK then
    alert "Rename failed!" -- or use baMsgBox
    else
    alert "File renamed to" &&fName -- or use baMsgBox
    member("txtFile").editable = 0
    end if

    4. Your keydown handler is attempting to rename the file on every
    keystroke. And you're getting the carriage returns because you have PASS
    in the case test for the ENTER and RETURN keys. I suggest putting the
    baRenameFile function in a separate handler of the script and call that
    handler when the keyDown event receives the enter key.

    on keyDown me
    case the key of
    ENTER,RETURN: renameIt(me)
    otherwise
    PASS
    end case
    end

    on renameIt me
    -- all your file renaming code goes here
    end

    5. You might want to consider trapping for illegal characters in the
    keyDown handler as well (":", "\", "/", etc...)


    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd Guest

  4. #4

    Default Re: buddy rename

    Hi mark,

    wow cheers for that
    i forgot to at that the script i posted was a movie script, that was
    triggered by the mousedown behavior on the rename button.
    is that a correct way to do it

    cheers
    lee

    "Mark A. Boyd" <mblistssanDotrr.com> wrote in message
    news:Xns93D753EA9AB87mblistssanDotrrcom65.57.83.2 09...
    > On 14 Aug 2003, "LeeD" <Baronyomo.com> wrote:
    >
    > > the name is placed into the field named 'txtfile'
    > > the rename buttons is pressed
    > > the field become editiable
    > > rename the file
    > > --press return to excute the renaming
    > > it then should check if the name exsists, if so add copy to the end of
    > > the name
    > >
    >
    > 1. You'll need to supply the full path to the destination name as well as
    > the source name.
    >
    > newName = the moviePath & "Tank\" &fieldName
    >
    > 2. You haven't checked whether the new file name exists. You'll probably
    > find it easier to prepend rather than append "copy" to the filename (as
    > Photoshop does) so you don't have to extract any file extensions.
    >
    > if baFileExists(newName) then
    > newName = tFilePath &"Tank\Copy of" &&fieldName
    > end if
    >
    > If you really want to append "copy" to the filename, you'll want to
    > extract the extension (if any) before appending, then tack the extension
    > back on. Setting the itemDelimiter to "." and getting the last item of
    > the string should get you started.
    >
    > 3. You'll need to determine success/fail by checking the OK variable
    > returned by baRenameFile().
    >
    > OK = baRenameFile(pdl, newName)
    > if NOT OK then
    > alert "Rename failed!" -- or use baMsgBox
    > else
    > alert "File renamed to" &&fName -- or use baMsgBox
    > member("txtFile").editable = 0
    > end if
    >
    > 4. Your keydown handler is attempting to rename the file on every
    > keystroke. And you're getting the carriage returns because you have PASS
    > in the case test for the ENTER and RETURN keys. I suggest putting the
    > baRenameFile function in a separate handler of the script and call that
    > handler when the keyDown event receives the enter key.
    >
    > on keyDown me
    > case the key of
    > ENTER,RETURN: renameIt(me)
    > otherwise
    > PASS
    > end case
    > end
    >
    > on renameIt me
    > -- all your file renaming code goes here
    > end
    >
    > 5. You might want to consider trapping for illegal characters in the
    > keyDown handler as well (":", "\", "/", etc...)
    >
    >
    > --
    > Mark A. Boyd
    > Keep-On-Learnin' :)

    LeeD Guest

  5. #5

    Default Re: buddy rename

    hi mark,
    why i was using the movie script was that i have to creat a duplication
    button has well,
    so the path and getting the name of the file would already be in place, and
    the rename script
    would need to be modified. but took what you have said and worked with the
    script.

    its returning 1 now seen i change
    OK = baRenameFile(tFilePath, newName)
    from
    OK = baRenameFile(pdl, newName) -- this what producing 0

    but changing the name in the field and pressing return still produces a
    carage return instead of executing.
    it seems i am almose there with your help
    but need help (the full script below - the script is a behavior - on the
    rename button)

    cheers
    lee


    --------------------------------------------------------------
    global clickme, pdl, tFilePath, delim, OK, rList, fieldName,RenameME,
    newName

    on mousedown me
    delim = the last char of the moviePath
    tFilePath = the moviePath & "Tank\" & pdl --F:\UNI
    Work\emd02\my_technical\Tank\awwee.TXT"
    fieldName = member("txtfile").text --awwee.TXT

    member("txtfile").editable = 1

    newName = the moviePath & "Tank\" &fieldName -- F:\UNI
    Work\emd02\my_technical\Tank\"
    end

    on keyDown me
    case the key of
    ENTER,RETURN: renameIt(me)
    otherwise
    PASS
    end case
    end

    on renameIt me
    OK = baRenameFile(tFilePath, newName)

    if NOT OK then
    alert "Rename failed!" -- or use baMsgBox
    else
    alert "File renamed to" && newName -- or use baMsgBox
    member("txtFile").editable = 0
    end if

    if baFileExists(newName) then
    newName = tFilePath &"Tank\Copy of" &&fieldName
    end if

    fieldname = member("txtfile").text
    OK = baRenameFile(pdl, fieldname )
    end


    LeeD Guest

  6. #6

    Default Re: buddy rename

    On 04 Sep 2003, "LeeD" <Baronyomo.com> wrote:
    > hi,
    > i have two scripts one on a button 'rename' the other 'field' on the
    > field all done with the help of mark.
    > but its working and not working to get it to work you have too
    >
    > click the rename button then change the name in the field then press
    > return then press the rename button again for it to rename
    > is there a way to just rename after the return is pressed
    Move the keyDown handler into a behavior script on your field sprite. If
    your field script is a behaviour, just move the keyDown handler into that
    script.


    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd Guest

  7. #7

    Default Re: buddy rename

    hi mark yeah the keydown was on the field script i messed up my last posting
    of the script, this is what the field script looks like:
    can figure it out it should work on the return
    cheers
    lee
    p.s. for the button script look at the previous posting before your reply.

    --------------------
    global clickme, pdl, tFilePath, delim, OK, rList, fieldName,RenameME,
    newName

    on keyDown me
    case the key of
    ENTER,RETURN: renameIt(me)
    otherwise
    PASS
    end case
    end

    on renameIt me
    OK = baRenameFile(tFilePath, newName)

    if NOT OK then
    alert "Rename failed!" -- or use baMsgBox
    else
    alert "File renamed to" && newName -- or use baMsgBox
    member("txtFile").editable = 0
    end if

    if baFileExists(newName) then
    newName = tFilePath &"Tank\Copy of" &&fieldName
    end if

    fieldname = member("txtfile").text
    OK = baRenameFile(pdl, fieldname )
    end
    "Mark A. Boyd" <mblistssanDotrr.com> wrote in message
    news:Xns93EE4D770AB20mblistssanDotrrcom65.57.83.2 09...
    > On 04 Sep 2003, "LeeD" <Baronyomo.com> wrote:
    >
    > > hi,
    > > i have two scripts one on a button 'rename' the other 'field' on the
    > > field all done with the help of mark.
    > > but its working and not working to get it to work you have too
    > >
    > > click the rename button then change the name in the field then press
    > > return then press the rename button again for it to rename
    > > is there a way to just rename after the return is pressed
    >
    > Move the keyDown handler into a behavior script on your field sprite. If
    > your field script is a behaviour, just move the keyDown handler into that
    > script.
    >
    >
    > --
    > Mark A. Boyd
    > Keep-On-Learnin' :)

    LeeD Guest

  8. #8

    Default Re: buddy rename

    On 06 Sep 2003, "LeeD" <Baronyomo.com> wrote:
    > hi mark yeah the keydown was on the field script i messed up my last
    > posting of the script, this is what the field script looks like:
    > can figure it out it should work on the return
    > cheers
    I think we're making it harder than it should be. I've tested this and it
    works here. I have only used the 'pdl' global here and had to hard-code
    it for my test, so it doesn't set all those other globals you have. If
    you still need those other globals for use in other scripts, just modify
    this script as needed.

    -- behavior on button sprite
    on mouseUp me
    member("txtFile").editable = 1
    end

    -- behavior on field sprite
    property pMember
    property pPath
    property pFileName
    global pdl

    on beginSprite me
    pdl = the moviePath &"Tank\awwee.TXT"
    pMember = sprite(me.spriteNum).member
    pPath = the moviePath &"Tank\"
    end

    on keyDown me
    case the key of
    ENTER,RETURN: renameIt(me)
    otherwise
    PASS
    end case
    end

    on renameIt me
    pMember.editable = 0
    newName = pMember.text
    fName = pPath &newName
    if baFileExists(fName) then
    alert "File already exists!"
    else
    OK = baRenameFile(pdl, fName)
    if OK then
    pdl = fName -- reset global to new existing file name
    else
    alert "Rename failed!"
    end if
    end if
    end



    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd Guest

  9. #9

    Default Re: buddy rename

    hi mark
    nah it not working at all, ive uploaded the movie i am working on its
    windows only using director 8.5
    [url]www.yomo-interactive.com/uni/unitest/lee01.zip[/url]

    i copied and pasted your script into it, i dunno if its because in your
    script your referencing a particular file i.e. Tank\awwee.TXT where the old
    script use the selected file name take a look at my movie
    i have included the tank folder where the files are referenced.

    thank you so much for your time on this mark - nice one

    lee

    "Mark A. Boyd" <mblistssanDotrr.com> wrote in message
    news:Xns93EE5CC9E6379mblistssanDotrrcom65.57.83.2 09...
    > On 06 Sep 2003, "LeeD" <Baronyomo.com> wrote:
    >
    > > hi mark yeah the keydown was on the field script i messed up my last
    > > posting of the script, this is what the field script looks like:
    > > can figure it out it should work on the return
    > > cheers
    >
    > I think we're making it harder than it should be. I've tested this and it
    > works here. I have only used the 'pdl' global here and had to hard-code
    > it for my test, so it doesn't set all those other globals you have. If
    > you still need those other globals for use in other scripts, just modify
    > this script as needed.
    >
    > -- behavior on button sprite
    > on mouseUp me
    > member("txtFile").editable = 1
    > end
    >
    > -- behavior on field sprite
    > property pMember
    > property pPath
    > property pFileName
    > global pdl
    >
    > on beginSprite me
    > pdl = the moviePath &"Tank\awwee.TXT"
    > pMember = sprite(me.spriteNum).member
    > pPath = the moviePath &"Tank\"
    > end
    >
    > on keyDown me
    > case the key of
    > ENTER,RETURN: renameIt(me)
    > otherwise
    > PASS
    > end case
    > end
    >
    > on renameIt me
    > pMember.editable = 0
    > newName = pMember.text
    > fName = pPath &newName
    > if baFileExists(fName) then
    > alert "File already exists!"
    > else
    > OK = baRenameFile(pdl, fName)
    > if OK then
    > pdl = fName -- reset global to new existing file name
    > else
    > alert "Rename failed!"
    > end if
    > end if
    > end
    >
    >
    >
    > --
    > Mark A. Boyd
    > Keep-On-Learnin' :)

    LeeD Guest

  10. #10

    Default Re: buddy rename

    On 06 Sep 2003, "LeeD" <Baronyomo.com> wrote:
    > hi mark,
    > i made some changes and it works!!! yeahhhh and its works perfectly.
    Excellent!
    > ive
    > posted ii in this post, for you to look at and anyone interested.
    Always good to follow up with the solution.
    > cheers for the time and the help on getting this done.
    Glad to help, I'm just sorry my response times have been sluggish.


    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd Guest

  11. #11

    Default Re: buddy rename

    hi mark

    nah, you when beyond to call of duty :)
    > Glad to help, I'm just sorry my response times have been sluggish.
    cheers
    lee


    LeeD Guest

Similar Threads

  1. BUDDY API HELP
    By James in forum Macromedia Director Lingo
    Replies: 4
    Last Post: March 2nd, 12:15 AM
  2. Need help with Buddy API
    By ombdinc webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 15
    Last Post: November 29th, 03:40 PM
  3. buddy api
    By Word of Mouth Productions in forum Macromedia Director Lingo
    Replies: 8
    Last Post: September 8th, 01:43 AM
  4. w3d buddy api
    By LeeD in forum Macromedia Director 3D
    Replies: 0
    Last Post: September 4th, 04:35 PM
  5. what is buddy api ?
    By gordonit webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 1
    Last Post: August 26th, 07:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139