Jump to content

Variable —> Change value with a php script

Recommended Posts

I have a question that seems so stupid - I could cry.

I need to change a value of a variable with a script. The language I know best is php. 

So just for example, without much logic. Of course I want to do something more fancy, but for an hour I am reading myself through the forum and don't find any solution:


1. I set a variable 'test' to the value 100 with Utilities —> Args and Vars.
2. I run a php script like <?php $test = 200; ?>
3. I want to make an output as Large Type to check if it was successful.


Whatever I try: The output is still 100. I wrote:
$test = 200;
$test = '200';
$var['test'] = 200;


Is there a way to change the value of a defined variable an go on in the script?

Many thanks for help.

Link to comment

Welcome @pilz,


When you’re using (including changing) the variable inside a Run Script, you’re doing so inside that Run Script. You’re not changing Alfred’s variable, you’re changing a copy of it inside your language that has the same name and value.

To make your new value carry on, you’ll need to either reset the variable in a new Argument and Variables Utility (you can get the new value with {query}) or outputting a format Alfred understands is a configuration.

Link to comment

Thank you vitor, I will try your solution.


Thank you also deanishe, but instead of your sticky note, you should think about updating your help-information that is linked in the app. Grüße nach Essen, ich wollte gerade schreiben, dass ich kein native englisch speaker bin. Hab wirklich über ne Stunde mit der Suchfunktion gesucht. Muss allerdings zu meiner Schande gestehen, dass mein Hirn automatisch JSON ausgefiltert hat. Das wäre ja ne Lösung gewesen.

Link to comment
4 hours ago, pilz said:

you should think about updating your help-information that is linked in the app


The thing is, the problem you were having was largely due to a misunderstanding of the UNIX execution model. With the best will in the world, that's outside the scope of the Alfred documentation.


4 hours ago, pilz said:

Das wäre ja ne Lösung gewesen.


Die einzige sogar, wenn du direkt von einer Skript aus Alfreds Variablen ändern möchtest. So oder so muss ein echo her: Andere Prozesse wissen nix von den Variablen innerhalb deiner PHP-Skript.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...