revCopyFile

David Vaughan drvaughan55 at mac.com
Wed Apr 24 17:00:02 EDT 2002


Karl, Jan and all

I have now received quite a few messages on this and am grateful for the 
assistance. I will not, however, be able to set aside time to test the 
various things properly until the weekend, so be patient with me. I am 
fairly confident the suggestions will help me resolve it at this stage.
And to the query of one of the responders, yes, "elsewhere" is the name 
of the hard disk on my portable. The desktop is somewhere. You have to 
have a convention :-)

thanks
david

On Thursday, April 25, 2002, at 03:23 , Karl Petersen wrote:

> David,
>
> After the revCopyFile call, try looking at the result. If it is 
> "execution error" then something went wrong with the AppleScript. (In 
> the Mac OS, revCopyFile uses AppleScript to "tell" the Finder to copy 
> the file to the destination folder. Presumably revCopyFile uses the 
> Finder's "duplicate" AppleScript command.) If the result is a long 
> expression showing the location of the new file, the AppleScript was 
> successful.
>
> Try adding something like this to your script. (The comments explain 
> the result.)
>
>   revCopyFile sPath,dPath -- in Mac OS, revCopyFile uses AppleScript to 
> duplicate the file
>   put the result into tResult
>
>   if word -3 to -1 of tResult is ("of application" && quote & 
> "Finder" & quote)
>   then put "copied successfully" into tResult
>   put sPath & return & dPath & return & tResult
>
>   -- if the AppleScript is successful, the Finder returns a long 
> expression
>   -- beginning with the new file name, followed by all parent folder 
> names,
>   -- ending with these three words: of application "Finder"
>
>   -- But if the AppleScript fails, revCopyFile returns "execution error"
>
>   -- "execution error" occurs If the destination folder does not exist,
>   -- or a file with that name already exists in the destination folder.
>   -- The AppleScript probably returns a long error to revCopyFile, 
> which in
>   -- which in turn returns "execution error" to the calling handler.
>
>   -- If AppleScript is disabled or not installed, revCopyFile
>   -- returns "Error: AppleScript not installed"
>
>   -- Although the Finder's "duplicate" AppleScript command accepts a 
> parameter
>   -- for replacing an existing file, apparently revCopyFile doesn't use 
> that parameter.
>   -- So it's the responsibility of the scriptor to delete that
>   -- file before creating the duplicate. It's also the responsibility 
> of the scriptor
>   -- to create the destination folder, if that doesn't exist.
>
> Presumably the Finder reports additional errors when permissions 
> disallow copying a file to the destination folder.
>
> Last resort: If revCopyFile fails when you KNOW the source file exists, 
> and the destination folder exists, and there's not already a file with 
> that name in the destination folder, try a script that calls 
> revCopyFolder to copy a folder to another folder. For some reason my 
> revCopyFile started to work after I tried revCopyFolder, which failed 
> at first with a very strange "binary code error" or something, then it 
> began to work. I'm not sure if I had done something wrong in my calls 
> to revCopyFile and revCopyFolder or what. But after some more fiddling, 
> both started to work.
>
> Karl
>
> On Thursday, April 18, 2002, at 07:13 , David Vaughan wrote:
>
>> I am trying to use revCopyFile for the first time. In the course of 
>> trying to work out why it does not do it for me, I put the following 
>> test script in the message box:
>>
>> put "/Elsewhere/Users/davidv/Desktop/Telstra usage" into sPath
>> put "/Elsewhere/Users/davidv/tmp/" into dPath
>> put spath & return & dpath
>> revCopyFile spath,dpath
>>
>> The message box shows the two paths as written above, but no copy 
>> happens (and nor if I include a file name as part of dPath).
>>
>> If I switch the last two lines, thus:
>>
>> put "/Elsewhere/Users/davidv/Desktop/Telstra usage" into sPath
>> put "/Elsewhere/Users/davidv/tmp/" into dPath
>> revCopyFile spath,dpath
>> put spath & return & dpath
>>
>> Then not only does the copy not happen but the message box remains 
>> obstinately empty.
>>
>> What gives, please?
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list