> 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
> 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)
> end case
> on renameIt me
> -- all your file renaming code goes here
> 5. You might want to consider trapping for illegal characters in the
> keyDown handler as well (":", "\", "/", etc...)
> Mark A. Boyd
> Keep-On-Learnin' :)