Link command fails in mac-standalone
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Link command fails in mac-standalone
Hi
I have some options for users to produce link-buttons to folders, programs and files in their diary. These options works nicely also in standalones on windows, and in the prototype Mac version, but they fail in a funny way in Mac standalones, because I get an error message saying, that they do not find...and then specifies the full and exact address of the file they say they cannot find..
button ”Filetype”:
on mouseUp
if (there is a file (the cFile of me)) then
if the platform is "MacOS" then
put revmacfromunixpath(the cFile of me) into myFile
put "tell application 'Finder'" & return & "activate" & return & \
"open file'" & myFile & quote & return & "end tell" into myScript
replace "'" with quote in myScript
replace slash with colon in myScript
do myScript as AppleScript
else if the platform is "Win32" then
put "start '' '" & the cFile of me & quote into myShell
replace "'" with quote in myShell
get shell(myShell)
else beep
else if the cFile of me is empty then
beep
answer error "Sorry, no File has been set." with "Okay"
else
beep
answer error "Sorry, I can't find file" && the cFile of me
end if
....etc
The script of the link to program is slightly different:
on mouseUp
if (there is a file (the cFile of me) or there is a folder (the cFile of me)) then
put empty into rslt
if the platform is "MacOS" then
put revmacfromunixpath(the cFile of me) into myFile
put "tell application 'Finder'" & return & "activate" & return & \
"open file'" & myFile & quote & return & "end tell" into myScript
replace "'" with quote in myScript
replace slash with colon in myScript
do myScript as AppleScript
put the result into rslt
else if the platform is "Win32" then
put "start '' '" & the cFile of me & quote into myShell
replace "'" with quote in myShell
get shell(myShell)
put the result into rslt
else
beep
end if
if rslt is empty then
close stack "stormaske"
set the iconic of stack "phenomenalog" to true
else
beep
answer error "Sorry, an error occurred" with "OK"
end if
else if the cFile of me is empty then
beep
answer error "Sorry, no File has been set." with "Okay"
else
beep
answer error "Sorry, I can't find file" && the cFile of me
end if
ikonide
end MouseUp
I must admit that I don't understand what the reference to "result" and rslt means, perhaps an early attempt to repair the bug.
But as even the link to file doesn't function I would disregard it, until further.
Hope somebody have an idea how to repair
best regards
Kresten Bjerg (www.phenomenalog.dk)
I have some options for users to produce link-buttons to folders, programs and files in their diary. These options works nicely also in standalones on windows, and in the prototype Mac version, but they fail in a funny way in Mac standalones, because I get an error message saying, that they do not find...and then specifies the full and exact address of the file they say they cannot find..
button ”Filetype”:
on mouseUp
if (there is a file (the cFile of me)) then
if the platform is "MacOS" then
put revmacfromunixpath(the cFile of me) into myFile
put "tell application 'Finder'" & return & "activate" & return & \
"open file'" & myFile & quote & return & "end tell" into myScript
replace "'" with quote in myScript
replace slash with colon in myScript
do myScript as AppleScript
else if the platform is "Win32" then
put "start '' '" & the cFile of me & quote into myShell
replace "'" with quote in myShell
get shell(myShell)
else beep
else if the cFile of me is empty then
beep
answer error "Sorry, no File has been set." with "Okay"
else
beep
answer error "Sorry, I can't find file" && the cFile of me
end if
....etc
The script of the link to program is slightly different:
on mouseUp
if (there is a file (the cFile of me) or there is a folder (the cFile of me)) then
put empty into rslt
if the platform is "MacOS" then
put revmacfromunixpath(the cFile of me) into myFile
put "tell application 'Finder'" & return & "activate" & return & \
"open file'" & myFile & quote & return & "end tell" into myScript
replace "'" with quote in myScript
replace slash with colon in myScript
do myScript as AppleScript
put the result into rslt
else if the platform is "Win32" then
put "start '' '" & the cFile of me & quote into myShell
replace "'" with quote in myShell
get shell(myShell)
put the result into rslt
else
beep
end if
if rslt is empty then
close stack "stormaske"
set the iconic of stack "phenomenalog" to true
else
beep
answer error "Sorry, an error occurred" with "OK"
end if
else if the cFile of me is empty then
beep
answer error "Sorry, no File has been set." with "Okay"
else
beep
answer error "Sorry, I can't find file" && the cFile of me
end if
ikonide
end MouseUp
I must admit that I don't understand what the reference to "result" and rslt means, perhaps an early attempt to repair the bug.
But as even the link to file doesn't function I would disregard it, until further.
Hope somebody have an idea how to repair
best regards
Kresten Bjerg (www.phenomenalog.dk)
Re: Link command fails in mac-standalone
Hi Kresten
try this, crossplatform and pure Livecode
Best
Klaus
try this, crossplatform and pure Livecode

Code: Select all
on mouseUp
put the cFile of me into tFile
## First check for something that will need to EXIT the handler, this will avoid too many nested "IF... THEN..." cases:
if tFile = empty then
beep
answer error "Sorry, no File has been set." with "Okay"
exit mouseup
end if
if there is NOT a file tFile OR there is NOT a folder tFile then
beep
answer error "Sorry, I can't find file" && the cFile of me
exit mouseup
end if
## Use LAUNCH instead of messing around with other scripting languages :-)
launch document tFile
if the result <> EMPTY then
answer error "Sorry, an error occurred" with "OK"
exit mouseup
end if
## File/folder successfully LAUNCHED, now do the rest:
close stack "stormaske"
set the iconic of stack "phenomenalog" to true
## more code here...
end MouseUp
Klaus
Re: Link command fails in mac-standalone
Thank you for your suggestion, but I tried it out, and I get exactly the same paradoxical errormessage, specifying the adress and saying, that it cant find the file. Same result from linking an .app, a .html file or a .txt file. A parallel link-to-folder function works fine.
The new script even doesnt work in the clone (the livecode stack)- = gives the same silly reply.
The new script even doesnt work in the clone (the livecode stack)- = gives the same silly reply.

Re: Link command fails in mac-standalone
Hi Kresten,
how do you "save" the file that the user selected?
You must take it "as is" as returned from the "answer file..." dialog, no "revMacFromUnixPath" etc.!
Best
Klaus
how do you "save" the file that the user selected?
You must take it "as is" as returned from the "answer file..." dialog, no "revMacFromUnixPath" etc.!
Best
Klaus
Re: Link command fails in mac-standalone
Thanks for advice, but the answer script is only:
if it is "File" then
answer file ("Link to which file")
if it is empty then
exit link
else
put it into filesti
set itemdelimiter to "/"
put last item of filesti into btnname
select button "Filetype"
copy
end if
if range is "all" then
start editing group id 8679
paste
stop editing
end if
if range is "one" then
paste
end if
set the name of it to btnname
set the width of btn btnname to the formattedWidth of btn btnname
set the height of btn btnname to the formattedheight of btn btnname
set the textcolor of it to "Black"
set the loc of it to landing
set the visible of it to true
set the cFile of it to filesti
end if
By the way I had difficulty finding anything about the cfile concept in live code library
if it is "File" then
answer file ("Link to which file")
if it is empty then
exit link
else
put it into filesti
set itemdelimiter to "/"
put last item of filesti into btnname
select button "Filetype"
copy
end if
if range is "all" then
start editing group id 8679
paste
stop editing
end if
if range is "one" then
paste
end if
set the name of it to btnname
set the width of btn btnname to the formattedWidth of btn btnname
set the height of btn btnname to the formattedheight of btn btnname
set the textcolor of it to "Black"
set the loc of it to landing
set the visible of it to true
set the cFile of it to filesti
end if
By the way I had difficulty finding anything about the cfile concept in live code library
Re: Link command fails in mac-standalone
Hi Kresten,
Did you check the custom property to contain the correct filepath in the end?
I am just wildly guessing, sincew I have o clue so far...
This is just about storing and retrieving info to and from a custom property of any object (control)!
Best
Klaus
Looks OK.kresten wrote:...
set the name of it to btnname
set the width of btn btnname to the formattedWidth of btn btnname
set the height of btn btnname to the formattedheight of btn btnname
set the textcolor of it to "Black"
set the loc of it to landing
set the visible of it to true
set the cFile of it to filesti
end if
...
Did you check the custom property to contain the correct filepath in the end?
I am just wildly guessing, sincew I have o clue so far...
There is no "cFile concept"!kresten wrote:By the way I had difficulty finding anything about the cfile concept in live code library

This is just about storing and retrieving info to and from a custom property of any object (control)!

Best
Klaus
Re: Link command fails in mac-standalone
Yes !
And even in the live-code stack it doesnt work.
Whereas the original script (with apple script and result) does work in live-code stack, only not in standalones
best
Kresten
And even in the live-code stack it doesnt work.
Whereas the original script (with apple script and result) does work in live-code stack, only not in standalones
best
Kresten
Re: Link command fails in mac-standalone
Hi Kresten,
hmm, no more ideas...
I just tesetd this on my Mac:
1. set the cFile of a button to a user selected file
2. changed the NAME of the button to that filename
3. opened the file (just like doubleclicked in the FINDER) with:
...
put the cFile of me into tFile
launch document tFile
## Success!
...
Best
Klaus
hmm, no more ideas...
I just tesetd this on my Mac:
1. set the cFile of a button to a user selected file
2. changed the NAME of the button to that filename
3. opened the file (just like doubleclicked in the FINDER) with:
...
put the cFile of me into tFile
launch document tFile
## Success!
...
Best
Klaus
Re: Link command fails in mac-standalone
OK
I tried to comment(remove) :
if there is NOT a file tFile OR there is NOT a folder tFile then
beep
answer error "Sorry, I can't find file" && the cFile of me
exit mouseup
end if
and now at least it works in livecode !!!!
-how could that corrupt the handler ????
Hurrah !!! It also works in the standalones !!!!!!!
Klaus, You have helped me more times than i can remember. !
I am so gratefull !
Hope to stay in contact--- perhaps skype. My skype is "bethkresten"
I tried to comment(remove) :
if there is NOT a file tFile OR there is NOT a folder tFile then
beep
answer error "Sorry, I can't find file" && the cFile of me
exit mouseup
end if
and now at least it works in livecode !!!!
-how could that corrupt the handler ????
Hurrah !!! It also works in the standalones !!!!!!!
Klaus, You have helped me more times than i can remember. !
I am so gratefull !
Hope to stay in contact--- perhaps skype. My skype is "bethkresten"

Re: Link command fails in mac-standalone
Dag Kresten,
my pleasure
Best
Klaus
my pleasure

Best
Klaus