I recently found an error in the documentation for revZipAddItemWithData. Now I'm trying to do something similar, but this time using revZipAddUncompressedItemWithFile. I suspect I have a similar problem. I've tried every combination of quotes or no quotes around the arguments, with no luck.
I'm not having trouble with any other handlers reading or writing to the zip archive, just this one.
Any ideas?
command SaveIssue
put field "Archive Path" into tPath
ask file "Save as:" with "someimage.jpg"
put it into tFilePath
set itemDelimiter to slash
put item -1 of tFilePath into tFileName
revZipOpenArchive tPath, "update"
revZipAddUncompressedItemWithFile tPath, tFileName, "tFilePath"
revZipCloseArchive tPath
end SaveIssue
Using LiveCode 6.6.2 stable, Mac OSX 10.9.4
I get it working with no quotes around the arguments;
revZipAddUncompressedItemWithFile tPath, tFileName, tFilePath
However, it doesn't work with an archive that I create by right-clicking a file (on a Mac) and selecting 'Compress ...' (The archive is reported as 'damaged' if I try to open it afterwards!)
It does work with an archive created with LiveCode
Related
When I switched to MacOS Mojave, I was no longer able to save an Excel document as a PDF to a specific location using a macro.
I have had to save it to /Library/Group Containers/UBF8T346G9.Office/ and then move it to the Desktop by calling a script stored in /Library/Application Scripts/com.microsoft.Excel/.
This has worked for months. Someone who uses this macro/script combo has all of a sudden been unable to do so. No other user has a problem, some having the same combination of Excel and MacOS (16.29 and 10.14.6 respectively).
When she tries to run the macro, it throws
Invalid procedure call or argument (Error 5)
specifically on the line that calls this script.
There is another script at the beginning of the macro that does not take an argument and is working. I used MsgBox to see what string was being passed to AppleScriptTask, plugged it into the script using Script Editor, and ran it without issue.
Here is the AppleScript:
ExistsFile(sPath)
on ExistsFile(sPath)
set sPath to sPath as POSIX file
tell application "Finder" to set sPath to file sPath
set dest to (path to desktop)
move sPath to dest without replacing
end ExistsFile
Here is the call from the macro:
result = AppleScriptTask("moveToDesktop.scpt", "ExistsFile", sPath & strJobNumber & " Cover Page.pdf")
I tried the following based on what I have seen on other forums:
Set the filename to a variable and passing that to AppleScriptTask
Removing the extension in the script, removing the extension in the folder, and combinations of those two
In MacOS Mojave and newer, you'll need to do the following:
Open System Preferences - Security and Privacy - Privacy Tab - Automation - Excel ~ check off Finder.
Sounds like it could be a permissions error if it fails to run for one user only. This page has all the requirements to run the AppleScriptTask command. Possible solution could be to enable the correct permissions for the script to run using chmod command from terminal. This will provide permission for root and current user. If this doesn't work, double check that all the requirements are met on the user's system.
cd <path to script file>
sudo chmod 755 moveToDesktop.scpt
Its the spaces in the parameters you are passing to the AppleScript. You have at least one one before "Cover Letter.pdf" (and then one between "Cover" and "Letter"), probably in other cells as well that you are using to create the parameter.
I had the same problem as well as it was driving me mad that the AppleScript itself was working fine when feeding it the combined parameter directly.
I'm trying to get some data out of excel files. Never used excel before but I understand VB. So I have a file with a button my boss implemented as well as his code he used. Here is the code:
(you can see the "Get Data" button in there)
My exact problem is that I don't know a lot about excel so if someone could help me figure out what is going on as well as figuring out how to correctly use directories that would be awesome! For more context when you click the button it gets all files in the directory and then the user clicks a file then excel follows a macro to get some data out of sed file.
Right now it returns nothing but there is 5 files in that directory?
Here is what the default directory looks like after edit:
And here is the files in my directory:
As #Tim Williams says ... Insert the back slash after the folder name
DirNow = Dir(Range("DefaultDirectory") + "\WFP*", vbDirectory)
EDIT
Basic troublseshooting
Does it it compile?
Looks like "UserFormDataa" - should maybe be "UserFormData"
Add Debug.Print DirNow after it's set and show us the display
If that's not right add line
Debug.Print Range("DefaultDirectory") to makes sure range is defined properly
Remove vbDirectory - unless you're going to handle processing files under the matching sub-folders
You are missing the terminal backslash on your default directory.
C:\Users\CUCCOMTT\Desktop\Excel Project\
Otherwise you're looking for files named
C:\Users\CUCCOMTT\Desktop\Excel ProjectWFP
So, I'm incredibly new to LiveCode and I have an external file in the same directory as the .livecode file called 'words.txt', with english words, each on a new line. I plan to read this file into a variable and then pick a random word from that variable. However, I am stumped as to how I must find the file path and insert this into the syntax required for me to do this. My code is as follows:
put url ("binfile:" & filePathGoesHere) into dictionary
replace crlf with lf in dictionary
replace numToChar(13) with lf in dictionary
put any line of dictionary into randomword
The file path is supposed to be inserted into the code at filePathGoesHere. Once the program is compiled I will be moving it and its resources around a bit (from computer to computer), so, beyond the text file staying in the same folder as the compiled program, the file path will change. What extra code would I need to add to make this work, if the folder the compiled program and the txt file is in is called "MyProgram"?
Help is much appreciated, and if further specification is required I can provide it. I also have a folder called "resources" if moving it there can help.
If the stack you're building is for your own use, you can place external files anywhere, but if you're going to deliver your stack to other users, you need plan where you external files are going to be placed, and how.
An easy way to determine the path to a file that sits immediately outside your stack is using the stack's filename:
put the fileName of this stack into theFilePath
set the itemDel to "/"
put "words.txt" into the last item of theFilePath
Now theFilePath variable will an absolute path reference to your external file. If the file is placed inside a folder "TextFiles" you can do this:
put the fileName of this stack into theFilePath
set the itemDel to "/"
put "TextFiles/words.txt" into the last item of theFilePath
If you're going to deliver your stack to other people, you should write your external file/s into a common system folder, or you need to use an installer to define where your files/folders will be placed. Common folder paths are found using the specialFolderPath function:
put specialFolderPath("Documents") into the theFolderPath
A somewhat recent addition to LiveCode is a "Resources" folder -- specialFolderPath("Resources") -- which can be handy for delivering on desktop and mobile platforms. Also, keep in mind that few of these folders allow writing to existing files contained in them for security reasons. "Preferences" and "Documents" are two examples of folders where you can change the contents of files.
The LC dictionary contains details of each of the folders.
If you use the file: scheme instead of bindle: LiveCode will automatically convert end of line characters to LF, so that step may not be necessary. (Although you might need it if you are reading a text file produced in native Windows encoding on a Mac.) You don't even necessarily need to read it into a variable. You could do this:
put any line of URL ("file:" & specialFolderPath("resources") & "/words.txt") \
into tRandomWord
I'd like to write an AppleScript for replacing three system files with ones I've modified. I'd like to do this with an AppleScript instead of manually replacing them because I'll have to replace three files every time there's an OS X update. Specifically, I'll be replacing stock graphics drivers with ones I've modified to support a graphics card which is connected via Thunderbolt. Is it possible to write an AppleScript for replacing one file with another? I ask because I know that when you replace a file, a dialog pops up with three options, and I don't know how to address that.
You can do this with Finder:
set freshFile to choose file
tell application "Finder"
move freshFile to desktop replacing yes
end tell
All you need to do is work out the source and destination paths to completely automate the script.
Many scripters do not like working with Finder, for a variety of reasons. If you want something that is incredibly fast, you would use the do shell script inside of your AppleScript:
do shell script " mv -f ~/Desktop/ArlandaTilUppsala.pdf ~/Documents/Employ.pdf"
I have a delphi prog that reads from thousands of .txt script files that I have created over some years. I had to do some mass changes so used a search and replace program which in itself took a good few hours! The problem is now the top line of all the txt files seems to be messed up somehow - to me it looks fine however the delphi program doesn't read it and TortoiseSVN records it as a changed line!!
What on earth has happened and how might I resolve it? So far I'm having to delete all the files and remake them. Deleting the line and rewriting doesn't work - even Crtl+A and pasting the old file contents doesn't work! Its as if the header is corrupt?
Could it be a problem with end lines? (windows/UNIX/Mac are different eg \n or \n\r ) use an editor able to show special characters. I think you can with tortoise diff, switching the right option. Else, try with notepad++, for example