[REPOST] Private Variables

AkashiDom

Active member
Repost of:
Which the summary is;
Each run have personal version of the variable.

Check the full explaination in original post
 

Dm114

Well-known member
Repost of:
Which the summary is;
Each run have personal version of the variable.

Check the full explaination in original post
I've read your previous post and I honestly don't see what would be the goal and benefit...

I think that, rather than asking for very specific and personal requests Dev @MacroDroidDev probably won't fulfill them for various reasons, you'd better try to benefit MD power and versatility.

In this particular case, why wouldn't you use a kind of token (such as system time) on every macro run, and use dictionaries rather than regular variables with tokens as keys?
 

Endercraft

Moderator
In this particular case, why wouldn't you use a kind of token (such as system time) on every macro run, and use dictionaries rather than regular variables with tokens as keys?
How does the macro know which token to use? If you store it anywhere it could get overwritten by another instance.
 

Dm114

Well-known member
How does the macro know which token to use? If you store it anywhere it could get overwritten by another instance.
If only one instance can run at a time, it's obvious.

In case of several instances it would be a bit more tricky. Setting the token could be made via an array where the last run will use the token stored in the last item.

Honestly the initial request is not precise enough and it would be interesting to know exactly how it is supposed to work to find out the real best solution.
 

Endercraft

Moderator
Setting the token could be made via an array where the last run will use the token stored in the last item.
How does the macro know what instance it is? We can't store a number in a variable for the same reason and there isn't any magic text for this.
 

Dm114

Well-known member
How does the macro know what instance it is? We can't store a number in a variable for the same reason and there isn't any magic text for this.
The answer is the same as "What user am I? 1st, 2nd, 3rd..."

As I told previously I don't know and can't see what could be the use cases... Maybe you have a more precise idea: I'm nearly sure we could find a workaround.

Anyway, Jamie would have to face the same problem/question if such a feature had to be implemented.
 

AkashiDom

Active member
As I told previously I don't know and can't see what could be the use cases...
Usually being use where macro could be busy. Like a server macro(eg. Bot, Webhook, etc.)

Most of the time variable will get overwritten by previous run and the current run will get confused and showed different output to client/user.


I'm nearly sure we could find a workaround.
Tried. Failed.
I've tried to make a workaround like give it an array but the variable for index will get overwritten with future run.
I've also make that the run will get paused until previous run is complete and it won't work if there are 2 or more run waiting in line.

PS~ the reason I Italic the "run" to meant that the macro's action for some people that don't understand what I mean by run.
 
Last edited:

AkashiDom

Active member
I would think people will understand if they make themselves a Telegram bot macro that return random number using maybe /random command.

Then, you try to flood the bot with the command. Most of the command won't get a respond or it'll show the same output twice in a row.
The test is equivalent to if the bot is widely used in most group and user all keep using the bot command at the same time.
 

Endercraft

Moderator
I've also make that the run will get paused until previous run is complete and it won't work if there are 2 or more run waiting in line.
I've also tried to do this but the wait until trigger action isn't supported in action blocks (that's literally the only thing preventing me from making it work).
 

md_sgf

Well-known member
I've come across this issue quite a few times. Such as when a macro or action block is called by multiple different macros, at different times. Or when trying to eliminate multiple triggerings of a macro when it should only trigger once. I was trying to use a queue system. Haven't yet got it working .. can't recall why, maybe it was getting too complex for my poor wee brain.
 

Qarboz

Well-known member
I thought of a somewhat crude solution but it should work.
The variables used must be arrays

Action increment an int variable (e.g. count) by 1

If count=1
Your actions; use variables with index [1].
End if

If count=2
Your actions; use variables with index [2].
End if

If count=3
Your actions; use variables with index [3].
End if

...

If count=n
Your actions; use variables with index [n].
End if

Action decrease the count variable by 1

This system works if the number of consecutive calls does not exceed n, also it could be a problem if the value of the variable is needed for another macro as you would have n values.
 

AkashiDom

Active member
I thought of a somewhat crude solution but it should work.
The variables used must be arrays

Action increment an int variable (e.g. count) by 1

If count=1
Your actions; use variables with index [1].
End if

If count=2
Your actions; use variables with index [2].
End if

If count=3
Your actions; use variables with index [3].
End if

...

If count=n
Your actions; use variables with index [n].
End if

Action decrease the count variable by 1

This system works if the number of consecutive calls does not exceed n, also it could be a problem if the value of the variable is needed for another macro as you would have n values.
Could you provide an example of this system?
 

Qarboz

Well-known member
Could you provide an example of this system?

Test_multicall.png

I recognize that it is a bit of a piece of junk.
Flaws I have noticed:
- There is a limit of callbacks.
- If there are UIs in the actions it might give unexpected results.
- If you need to change the macro you have to repeat the changes n times, or repeat the copy paste and change all the array indexes.

But, I think, until a queuing system is implemented I don't think there are many other possibilities, IMHO

Edit
In the last action the constraint is wrong, it must be count>0
 
Last edited:

Qarboz

Well-known member
Come to think of it, the actions contained between IF and END IF can be placed in an action block. This makes it easier to make changes, and also to avoid errors in compiling array indexes. There remains the problem of using UIs, which may give unexpected results. Perhaps (perhaps!), a queuing system could be implemented by inserting a loop in the action block, but right now my brain is off and I can't think of how to do it.
 

Qarboz

Well-known member
New version with action block
There is also a very artisanal queue management, UI actions should work too

Test_multicall_2.png


Screenshot_20240915-224721-639.png


AB_Multicall.png

The waiting time can be decreased, to be tried.

I haven't tested it, I hope it works...
 
Top