LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
on mouseup
answer file "Please select an image file" as sheet
put it into tFile
set the itemDelimiter to "/"
-- grab file name
put the last item of tFile into tFileName
put item 1 to -2 of tFile into tCurrentFolder
put tCurrentFolder & "/" & "temp/" into tDestinationFolder
revCopyFile tFile, tDestinationFolder
answer the result
end mouseup
I get a result of execution error. I am on a Mac and looking at previous posts I understand that this is an AppleScript error. Can anyone tell me what I am missing?
on mouseup
answer file "Please select an image file" as sheet
put it into tFile
set the itemDelimiter to "/"
-- grab file name
put the last item of tFile into tFileName
## Now create target filename:
put tFile into tTargetFile
## We simply overwrite that pathname:
put ("temp/" & tFileName) into last item of tTargetFile
## Now use put url binfile... to let LC copy that thing:
put url("binfile:" & tFile) into url("binfile:" & tTargetFile)
## No uneccessary alerts... ;-)
if the result <> EMPTY then
answer ("TOOT TOOT TOOT" & CR & the result)
end if
end mouseup
I tried your script and it did not work for me. Then I was wondering if it is a permission problem. I am using MacOS 10.14.4 Mojave.
I copied the script that LC makes for AppleScript
tell application "Finder"
duplicate file "root:Users:user:Desktop:Bildschirmfoto 2021-11-19 um 12.17.12.png" to folder "root:Users:user:Desktop:temp"
return the result as text
end tell
And tried to run it from "ScriptDebugger" an application for debugging appleScript.
ScriptDebugger put up a dialog "You have to give ScriptDebugger permission to access "Finder" in order to run this script"
After I granted ScriptDebugger permission the script worked and did the copying.
So my conclusion is that LC does not have permission to acccess "Finder" for revcopyfile to work.
Permissions get to be more and more restrictive and confusing.
Kind regards
Bernd
Last edited by bn on Sat Dec 11, 2021 11:03 am, edited 1 time in total.
I played with permissions for LC in "Security" in "System Settings" of the Mac and it turned out that if I grant LC permission to use "Automation" and allow Finder access then your script works fine from the IDE.
on mouseup
answer file "Please select an image file" as sheet
put it into tFile
set the itemDelimiter to "/"
-- grab file name
put the last item of tFile into tFileName
put item 1 to -2 of tFile into tCurrentFolder
put tCurrentFolder & "/" & "temp" into tDestinationFolder
if there is a folder tDestinationFolder then
revCopyFile tFile, tDestinationFolder
else
create folder tDestinationFolder
revCopyFile tFile, tDestinationFolder
end if
answer the result
end mouseup
on mouseup
answer file "Please select an image file" as sheet
put it into tFile
set the itemDelimiter to "/"
-- grab file name
put the last item of tFile into tFileName
## Now create target filename:
put tFile into tTargetFile
## We simply overwrite that pathname:
## Fist check for existence of folder TEMP
put "temp" into last item of tTargetFile
## Create if neccessary:
if NOT (there is a folder tTargetFile) then
create folder tTargetFile
end if
## Create the final filename:
put ("/" & tFileName) AFTER tTargetFile
## Now use put url binfile... to let LC copy that thing:
put url("binfile:" & tFile) into url("binfile:" & tTargetFile)
## No uneccessary alerts... ;-)
if the result <> EMPTY then
answer ("TOOT TOOT TOOT" & CR & the result)
end if
end mouseup