Dwight Posted July 10, 2019 Share Posted July 10, 2019 Hello all, I defined a variable "input" as Workflow Environment Variable in a workflow. Especially it is the "Leo Dictionary" workflow from Bastian Ohmer. The script in the script filter is: require('leo.php'); $in = "{query}"; $leo = new Leo("ende"); echo $leo->getTranslations($in); with Language: /usr/bin/php, "with input as {query}" and as Escaping "Double Quotes" and "Dollars". I would like to assign "{query}" to my my "input" environment variable in order to be able to use it after the script filter in other action modifiers. Everything I tried failed. E.g.: require('leo.php'); $in = "{query}"; SetEnv $input $in; $leo = new Leo("ende"); echo $leo->getTranslations($in); ==> Code 254: Parse error: syntax error, unexpected '$input' (T_VARIABLE) in Command line code on line 4 Any ideas how to solve it? Thank you very much Link to comment
deanishe Posted July 10, 2019 Share Posted July 10, 2019 You appear to be trying to use an Apache command in PHP. I don’t think you’ve quite understood how variables work. Here’s an article describing how to use them. I don’t know the workflow you’re talking about, so I might be wrong, but I think you’ll have to change its “innards” if you want to set variables. Link to comment
Dwight Posted July 10, 2019 Author Share Posted July 10, 2019 Thank you for the help. I now understood that I have to output a certain JSON in order to assign values to environment variables. I did not really understood the Leo workflow but I assume you are right: Probably the PHP code itself must be changed. Will try to figure it out some day later. Link to comment
deanishe Posted July 10, 2019 Share Posted July 10, 2019 (edited) 2 hours ago, Dwight said: Probably the PHP code itself must be changed. If it’s a Script Filter, then yes, you’ll definitely have to change the PHP code, but nothing massive (hopefully). If you post a link to the workflow you’re talking about, I (or someone who really knows PHP) could point you in the right direction. Edited July 10, 2019 by deanishe Link to comment
Dwight Posted July 11, 2019 Author Share Posted July 11, 2019 Ok, thank you. The workflow is called Leo Dictionary and you can find it on https://github.com/psistorm/alfredapp What I figured out so far: The Script Filter is using a script leo.php leo.php is using a function toxml() of workflow.php to generate an XML file toxml() is mainly generating an item list Alfred comes with an Advanced Script Filters example workflow and the script filter called xvar is giving an example of how to work with variables ==> In my opinion it should work if the toxml() function will be extended in such a way, that it also puts the variable I need into the XML file. This would be a kind of dirty approach but on the other hand the Leo workflow is not under development anymore and XML is deprecated. So, it would not make to much sense to put a lot of effort into changes. I do not know PHP neither but I have the impression this "hack" could not to be that complicated Link to comment
deanishe Posted July 11, 2019 Share Posted July 11, 2019 In theory, you need to update the item-adding API to accept variables, and the XML-generation code to output them. I can't say anything else, as the workflow has been taken down, and I don't have it. Link to comment
Dwight Posted July 12, 2019 Author Share Posted July 12, 2019 Done. It was tricky because I do not know PHP but now its exactly working how I want it to 🙂 Thank you deanishe for your valuable help 👍 deanishe 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now