Can LC copy a shortcut to desktop? - Solved

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Can LC copy a shortcut to desktop?

Post by FourthWorld »

In many cases, when code doesn't work you can check the value of the local variable "the result" to determine the cause, e.g.:

Code: Select all

put specialfolderpath("desktop") & "/Books.exe" into tFile
put url("binfile:" & "/David3A/Books.exe") into url("binfile:" & tFile)
if the result is not empty then
  answer the result
end if
The dirty secret that no one tells us at the start is that only half of programming is writing features; the other half is adding error-checking and error-handling code, which is much less fun but no less necessary. Things fail for all sorts of reasons - in this case checking the result would let you know that the path is invalid.

Tedious as it can be to do well, error-handling makes a huge difference in the quality of the user experience. Without it, things just break and users get frustrated that they don't know why, but with it you can understand what went wrong and provide guidance to the user to get them through most anything that happens.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LC copy a shortcut to desktop?

Post by DR White »

Klaus,

I am sad to report that your recommended action did not work, see my code below:

----- Copy file David3A/Books.exe to Desktop
put specialfolderpath("desktop") & "/Books.exe" into tFile

put url("binfile:" & "c:/David3A/Books") into url("binfile:" & tFile)
----------------------------------------------------
I get an icon on the desktop, but when I right click and check the size of the file its shows 0 bytes (and of course it does not run)

Can LC copy .exe files? If so, HOW?

Thanks,

David
SparkOut
Posts: 2984
Joined: Sun Sep 23, 2007 4:58 pm

Re: Can LC copy a shortcut to desktop?

Post by SparkOut »

Yes it can.

Look at what you have asked to put into the destination binfile.

url ("binfile:" & "c:/David3A/Books") looks like a folder to me. Surely you need to:

put url ("binfile:" & "c:/David3A/Books/books.exe") into <the destination>?
??

But why are you copying the exe file to the desktop?

Don't you want (after all, this is the topic) to:

create alias specialFolderPath("desktop") & "/books.lnk") to file "c:/David3A/Books/books.exe"
??
Last edited by SparkOut on Wed Dec 11, 2013 11:43 pm, edited 1 time in total.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can LC copy a shortcut to desktop?

Post by Klaus »

Hi David,

this line:

Code: Select all

put url("binfile:" & "C:/David3A/Books") into url("binfile:" & tFile)
Should read:

Code: Select all

put url("binfile:" & "C:/David3A/Books.exe") into url("binfile:" & tFile)
Find the difference :D


Best

Klaus
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LC copy a shortcut to desktop?

Post by DR White »

All You GOOD People!

It finally works! :D

I cannot believe that a couple of typos could cause me so much PAIN!

I want to thank each of YOU for being so supportive in my days of disbelief!

Keep up the Great support for us Newbies :D :D

The working code example is :


----- Copy file David3A/BibleBooks.exe to Desktop
put specialfolderpath("desktop") & "/Bible Books.exe" into tFile

put url("binfile:" & "c:/David3A/Bible Books.exe") into url("binfile:" & tFile)

if the result is empty then
answer the result
end if

-------------------------------------------------------------

David
Last edited by DR White on Wed Dec 11, 2013 11:51 pm, edited 1 time in total.
SparkOut
Posts: 2984
Joined: Sun Sep 23, 2007 4:58 pm

Re: Can LC copy a shortcut to desktop?

Post by SparkOut »

Are you sure the source path is correct?

It isn't maybe: "c:/Users/David3A/BibleBooks.exe" that you need?

And again, are you really trying to copy the file or make a shortcut? (see above)
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LC copy a shortcut to desktop?

Post by DR White »

SparkOut,

I originally was trying to put a shortcut to desktop, but that seemed impossible and it appeared to be easier to copy the application to the desktop.
So I switched my efforts to put the application to desktop.

Thanks,

David
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LC copy a shortcut to desktop?

Post by DR White »

Thanks to everybody's help Below is the code to copy shortcut or .exe (change extension) to Desktop


----- Copy shortcut to Desktop
put specialfolderpath("desktop") & "/Bible Books.lnk" into tFile

put url("binfile:" & "c:/David3A/Bible Books.lnk") into url("binfile:" & tFile)

:D :D

David
SparkOut
Posts: 2984
Joined: Sun Sep 23, 2007 4:58 pm

Re: Can LC copy a shortcut to desktop? - Solved

Post by SparkOut »

There is something very strange if:

create alias specialFolderPath("desktop") & "/Bible Books.lnk") to file "c:/David3A/Books/Bible Books.exe"

is not really the right way to do it. Changing a file extension doesn't actually change its functionality.
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LC copy a shortcut to desktop? - Solved

Post by DR White »

SparkOut,

No No No

Changing the file extension did not make a shortcut.

I had to first use windows to make a shortcut in the same directory with the application.

After having both the application and the shortcut in the same directory,

I then copied the files with the code above.

Hope this clears things up,

David
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can LC copy a shortcut to desktop? - Solved

Post by Klaus »

Hi David,

some hints:

Code: Select all

...
----- Copy file David3A/BibleBooks.exe to Desktop
put specialfolderpath("desktop") & "/Bible Books.exe" into tFile
put url("binfile:" & "c:/David3A/Bible Books.exe") into url("binfile:" & tFile)

if the result is empty then
answer the result
end if
...
why answer an EMPTY result?

If the result = EMPTY then it means SUCCESS!
If the result is NOT EMPTY, then it will contain the possible error and you should ANSWER it to get a hint! :D


Best

Klaus
Post Reply