Jump to content
pilz

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;
$args['test'];
$vars...
$variables...

 

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

Many thanks for help.

Share this post


Link to post

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.

Share this post


Link to post
13 hours ago, pilz said:

for an hour I am reading myself through the forum and don't find any solution:

 

There's a fairly comprehensive post stickied at the top of this forum.

 

 

Share this post


Link to post

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.

Share this post


Link to post
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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...