Post

Replies

Boosts

Views

Activity

Reply to Can we integrate and use a library written in python in iOS app?
Apps need to be self-contained and can't read or write data outside their containers, or download or execute code that change its features or functionality, but there are applications in the store that contain interpreters to run code - Pythonista, for example (not to mention web browsers). But yes, for a library it would be better to build one from Python code rather than embedding a multi-megabyte interpreter for it.
Dec ’19
Reply to AppleScript pass variables to shell script
Errors in folder actions will fail silently unless you trap them. You can use a try statement, but in your snippet you are ignoring any errors, such as:AppleScript itself doesn't know about file names, so you need to use something that does, such as Finder;The shell uses spaces as delimiters between arguments, so you need to make sure they are used as needed when appending the various text items;File paths should be quoted or special characters (spaces, etc) otherwise escaped to prevent misinterpretations.I don't know the purpose of passing the folder name in addition to the full path (also note that a list of the dropped items are passed to the handler in the added_items argument), but after fixing the above items, your snippet would be something like:on adding folder items to this_folder after receiving added_items try tell application "Finder" to set filename to name of this_folder set p to quoted form of POSIX path of this_folder do shell script "/path/to/script " & p & space & quoted form of filename on error errmess number errnum display alert "Error " & errnum message errmess end try end adding folder items to
Mar ’20
Reply to script editor
When using the repeat with X in Y form of the repeat statement, the loop variable X is actually a reference to an item in the list Y. Depending on what you are doing with the variable X, the value may not be dereferenced (yet), so comparisons can fail. To be sure you are using the value of X instead of its reference, you can coerce it to the desired class or get its contents, for example:if contents of X = "whatever" then somethingAlso note that index is reserved word (note the different font in the Script Editor), and may result in unexpected behavior if used as a variable name.(Edit: ninja'd by hhas01)
May ’20