revCopyFile and revCopyFolder to the "desktop"

Jim Ault JimAultWins at yahoo.com
Thu Jan 18 07:29:37 EST 2007


A couple specific comments:
> did not work
>       put specialFolderPath("DeskTop") into GVDeskTop
>       set the defaultFolder to GVDeskTop
>       revCopyFile "/MyFolder/MyFile.rev","MyFile.rev"
In the last line of this ..it does not look like you are naming a folder as
a destination.

> I assumed that a "revCopyFile" could be used to create a copy of a file
> with a new name (Why Not - It does not say that "fileToCopy" and
> "folderToCopyTo" must NOT use different filenames !).
The "folderToCopyTo" probably means 'folder' to copy to, not filename.

from the docs
The folderToCopyTo specifies the name and location of the FOLDER where the
copied file should be placed. If you specify a name but not a location,
Revolution assumes the destination folder is in the defaultFolder.

location = full path name /Users/jault/Documents/agreement.jpg
name = start with the default folder, thus nested.
/MyFolder/subFolder/ = defautFolder/ MyFolder/subFolder/

-----------------  further reading, esp error checking code
One tip for this:  most likely one of your folder variables did not look
like a folder or it has not been created yet, therefore setting the
defaultFolder was not possible, and it was not changed.

First
always put the path name into its own variable
and then put the filename into another.
Sometimes you will want the path or file or both.
Error checking is the main reason.

Then get in the habit of
 put specialFolderPath("DeskTop") into destPathh
if the last char of destPathh is not "/" then put "/" after destPathh

put destPathh & "MyFolder/"into sourcePathh
if there is not a folder sourcePathh then
answer "Oops!  There is no folder .." & sourcePathh
breakpoint
exit to top
end if

if there is not a folder destPathh then
answer "Oops!  There is no folder .." & destPathh
breakpoint
create folder destPathh
end if


put "MyFile.rev" into FN

put the defaultFolder into temp
breakpoint --be sure that it is where you think it should be

if there is not a file sourcePathh&FN then
answer "Oops!  There is no file .." & sourcePathh&FN
end if

revCopyFile (sourcePathh&FN), destPathh

if there is not a file destPathh&FN then
answer "Oops!  Did not copy.create file .." & destPathh&FN
end if
--------------------
another quick test method is to put this in the MULTI line message box

answer folder "pick a fat one"
put it & "/"

--> a full folder path will be returned

answer file "pick a crummy one"
put it

--> a full file path will be returned

------------------------------------
The way I do it does not use RevCopyFile or Folder
Same result, different form.

--for text files
put url ("file:"&pathh&FN) into url ("file:"&pathh2&FN2)
put fld 1 into url ("file:"&pathh&FN)
put fld 2 after url ("file:"&pathh&FN)
put fld 3 before url ("file:"&pathh&FN)

--for images
put url ("binfile:"&pathh&FN) into url ("binfile:"&pathh2&FN2)
-----------------------------------------------------------
Hope this helps with your designs

Jim Ault

On 1/18/07 3:38 AM, "Francis Nugent Dixon" <effendi at wanadoo.fr> wrote:

> Hi from Paris,
> 
> I am confused about the commands "revCopyFile" and "revCopyFolder", on
> both my Mac and on my PC, especially in the context of "desktop". I
> want to create files, folders and shortcuts on the Mac and PC desktops.
> 
> I am using Revolution DreamCard 2.6.1, build 152 on my Mac, and
> StackRunner 1.3.0.0 on my PC. I develop my stack on the Mac, and run it
> on both Mac and PC.
> 
> Here we go :
> 
> For "revCopyFile" and "revCopyFolder", documentation says " If you
> specify a name but not a location, Revolution assumes the destination
> file/folder is the defaultFolder." Does this mean that if the "
> folderToCopyTo " or "destinationFolder" DOES NOT begin with a "/", then
> defaultFolder is used as the destination folder ?
> 
> Supposing that this is true : revCopyFile
> "/MyFolder/MyFile.rev","MyFile.rev" could be used to create a copy on
> my desktop ...........
> 
> So I coded :
> 
>       put specialFolderPath("DeskTop") into GVDeskTop
>       set the defaultFolder to GVDeskTop
>       revCopyFile "/MyFolder/MyFile.rev","MyFile.rev"
> 
> On my Mac, GVDeskTop contains "/Users/francisdixon/Desktop"
> On my PC, GVDeskTop contains "C:/Documents and
> Settings/francisdixon/Desktop"
> 
> Because of my understanding of the documentation, I thought I would
> create a copy of my file on the deskTop. It didn't work ! The command
> appeared to execute, but no trace of my new file could be found, either
> on the desktop (or anywhere else on the disk). The Result showed no
> error.
> 
> So I tried trickery and subterfuge (this is a built-in function for an
> Irishman !), by naming the destination file specifically as the desktop
> :
> 
>       put specialFolderPath("DeskTop") into GVDeskTop
>       put GVDeskTop & "/" & "MyFile.rev" into GVMyDestination
>       revCopyFile "/MyFolder/MyFile.rev,GVMyDestination -- On the Mac
>       OR
>       revCopyFile "C:/MyFolder/MyFile.rev,GVMyDestination -- On the PC
> 
> This works on my Mac (the file appears immediately on the deskTop).
> On the PC, the file DOES NOT appear on the deskTop, but DOES APPEAR in
> the desktop folder itself :
> 
> Is this because the PC desktop needs to be "refreshed" just like any
> other folder ? If so, how would I do this ?
> When I rebooted my PC, my file then showed on the deskTop.
> 
> When I test "the Result" after a file copy, to see if the copy is
> successful, "the Result" should be empty (suggested by the
> documentation). I found that "the Result" contains the name of the file
> in quotes, after a successful copy. So how do I check for a failure in
> the copy ?
> 
> I assumed that a "revCopyFile" could be used to create a copy of a file
> with a new name (Why Not - It does not say that "fileToCopy" and
> "folderToCopyTo" must NOT use different filenames !). So I tried :
> 
> put specialFolderPath("DeskTop") into GVDeskTop
> put GVDeskTop & "/" & "MyFile.rev" into GVMySendingFile
> put GVDeskTop & "/" & "NewName.rev" into GVMyDestination
> revCopyFile GVMySendingFile,GVMyDestination
> 
> On my Mac, this renames my original file on the desktop to
> "NewName.rev", and creates a file "MyFile.rev copy" on the desktop. As
> Alice once said -  "Curiouser and curiouser !" (I haven't yet bothered
> to test this on my PC).
> 
> I am also having problems creating a shortcut on the PC desktop, but I
> will experiment further before asking for help !
> 
> Has anybody got any experience with these commands, especially
> concerning the destination  "desktop" ?
> 
> -Francis
> 
> "Nothing should ever be done for the first time !"
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list