Samrae Posted September 14, 2023 Report Share Posted September 14, 2023 In Macro Express 3 you have to change an setting to allow nesting of variables. Click Options, Preferences, Miscellaneous, the Advanced button, and enter something other than 0 in the Variables Evaluation Level box. Quote Link to comment Share on other sites More sharing options...
acantor Posted September 14, 2023 Report Share Posted September 14, 2023 I didn't remember that setting. My more "brute-force" method works, but I would prefer to use nested variables. Just an aesthetic choice. Something I find irritating about all of the script samples I've submitted in this thread: The variables get assigned every single time the macro runs. I would rather they get assigned once. If I were doing this again, I would use two scripts: the first script to load the variables into memory. You'd only need to trigger it once, at the start of a session. The variables would persist while Macro Express is running. The second script outputs the variables... and that's all it does, other than iterate the counter. Quote Link to comment Share on other sites More sharing options...
OldMacroDonald Posted September 28, 2023 Author Report Share Posted September 28, 2023 I tried to add a way to make the different texts (N1) start off with a random one on the first run of the day, rather than start at the first one every day. I made an If variable loop where if N2 is = 1 then it would change N1 to a random number, then increment N2 so that that loop won't run again. The problem is I can't get it to run at all, or it will run every time depending on if it happens before the Restore all variables line or after. Any ideas on what I'm doing wrong? Quote Link to comment Share on other sites More sharing options...
rberq Posted September 28, 2023 Report Share Posted September 28, 2023 How does N2 get set to "1" in the first place? Quote Link to comment Share on other sites More sharing options...
OldMacroDonald Posted September 28, 2023 Author Report Share Posted September 28, 2023 I had a line to set it to 1 but didn't know if it was doing anything so I removed it. Quote Link to comment Share on other sites More sharing options...
rberq Posted September 28, 2023 Report Share Posted September 28, 2023 I believe an integer variable will have the value zero if there have been no previous commands setting a value. Therefore N2 will NEVER be equal to 1, and the macro will NEVER set N1 to a random value -- at least the way the macro stands now. If you PREVIOUSLY set N2=1, and saved and restored variables every time the macro ran, then N2=1 would be true once and only once, and "never" again. But shutting down and restarting Macro Express would wipe out saved variables and you would be back to the original state where N2 will NEVER equal 1. And some unrelated macro, assuming you have some, could change the value of N2, then save variables, and this macro would pick up that saved value, whether it be 0 or 1 or 987654. Try making a second macro whose only function is to set N2=1 and save variables. Run that macro once at the beginning of each day, and I think it will make the random feature work the way you want it to. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.