Set Variable: Value + x?

My problem is that I can't figure out how to define a 'value + x' variable because it resets the value of the starting variable while value + 1 passes
 

420

Active member
When I receive a message I get a value in the message and I assign it to a variable now I want that when the next message arrives it makes the variable + the new value that I get
Do what Jacob said, set "variableX" to {lv=variableX}{message} or to {message}{lv=variableX} depending on whether you want to append or prepend. You can ofcourse also put something in between both values depending on your needs.
 
Faites ce que Jacob a dit, définissez "variableX" sur {lv=variableX}{message} ou sur {message}{lv=variableX} selon que vous souhaitez ajouter ou préfixer. Vous pouvez bien sûr également mettre quelque chose entre les deux valeurs en fonction de vos besoins.
 
It doesn't work

What triggers my actions is a message in this message is contained a value that I store in a variable in int now I would like that each time I receive the message it makes the previous value plus the new value. But each time the old value is erased and does not perform the calculation
 

420

Active member
It doesn't work

What triggers my actions is a message in this message is contained a value that I store in a variable in int now I would like that each time I receive the message it makes the previous value plus the new value. But each time the old value is erased and does not perform the calculation
What is the magic text for this message? I assume you are writing {message} to a string variable as your first action?

If you could post a screenshot that would probably help make clear what issue you are having, i had assumed your message consisted of text and you just wanted to log it, but maybe it's a number after all and you are looking to do a calculation..?
 
Quel est le texte magique de ce message ? Je suppose que vous écrivez {message} dans une variable de chaîne comme première action ?

Si vous pouviez publier une capture d'écran qui aiderait probablement à clarifier le problème que vous rencontrez, j'avais supposé que votre message était composé de texte et que vous vouliez simplement l'enregistrer, mais c'est peut-être un nombre après tout et vous cherchez à faire un calcul. .?
Screenshot_20221101-004358_MacroDroid.jpgScreenshot_20221101-004411_MacroDroid.jpg
 
I want that each time I retrieve in the variable intmontant it makes the calculation of the old value plus the new one and so on
 
No when I get the value in the message it is in string intmontant it is to put that in integer to be able to make the calculations
 
My problem is that every time I get a new message I would like it to add up to the previous value but the problem is that every time I get the new value in the message it deletes the old value before even doing the calculation
 
Oh dang, this screenshot is getting me even more confused! 😂 It seems very overcomplicated, writing the same value to three different variables and stuff..

Anyway, if you (for example) got the old value in "intMontant" and the new value in "montant" you should be able to just set "intMontant" to expression "{lv=intMontant}+{strval=montant}" (without quotes)
Screenshot_20221101-013256_MacroDroid.jpg
 
Whereas when I do an assignment with the plus one it keeps the previous value and it makes plus one like that it works but when it is another variable it does not work
 

OscariBot

Active member
From your screenshot and explanation above.

Just choose expression then set variable calcul with the expression {lv=calcul}+{lv=intMontant} NOT {lv=intMontant}+{lv=nb} like you did above. My idea will add the new value to the already existing value in calcul variable. Assuming your intention is increment by the value of intMontant variable.

Does this help?
 
From your screenshot and explanation above.

Just choose expression then set variable calcul with the expression {lv=calcul}+{lv=intMontant} NOT {lv=intMontant}+{lv=nb} like you did above. My idea will add the new value to the already existing value in calcul variable. Assuming your intention is increment by the value of intMontant variable.

Does this help?
I am really stupid I had the answer in front of me since the beginning. Thank you again for your help, the most difficult things I find when it is easy I don't find
 
From your screenshot and explanation above.

Just choose expression then set variable calcul with the expression {lv=calcul}+{lv=intMontant} NOT {lv=intMontant}+{lv=nb} like you did above. My idea will add the new value to the already existing value in calcul variable. Assuming your intention is increment by the value of intMontant variable.

Does this help?
Thank you very much indeed
 
Top