|
Post by zeak on Nov 27, 2018 23:05:10 GMT
Is there a way to save single INTEGERs externally either to a INPUT.mmmacro just used as a data file to then have certain INTEGERs be pulled back to the main macro when required?
Example of how I think it works:
1 | RUN ACTION | OUTPUT TO FILE | D:\Macro\RX\INPUT.mmmacro::OVERWRITE::%INTEGER1%::%INTEGER4% The line above if I can understand it correctly creates an INPUT.mmmacro file at the file path D:\Macro\RX\INPUT.mmmacro with the declared INTEGER1 overwritten with the information with INTEGER4 in the current macro for use with the INPUT FROM FILE action.
|
|
|
Post by Steve on Nov 28, 2018 4:06:18 GMT
A good way to get data into variables during run time is to use INPUT FROM FILE ( www.turnssoft.com/conditions.html#inputfromfile). 1 | RUN ACTION | INPUT FROM FILE | VARIABLES::REFRESH::D:\Macro\RX\VARS.txt Declared usually at the beginning of the macro, the INPUT FROM FILE condition above will monitor the VARS.txt for changes. Any changes that are made to the file will be added into the corresponding variables. For this to work, VARS.txt must be formatted correctly: VARS.txt INTEGER::10 INTEGER1::20 INTEGER2::30 INTEGER3::40 INTEGER4::50 STRING::Ant STRING1::Bee STRING2::Cat STRING3::Dog STRING4::%CLIPBOARD%If you do not intent to monitor all variables for changes then a single variable can be declared. Like we did here: getres.mmmacro can assign the resolution to variables. I think this is what you are after. getres.mmmacro uses 'wmic' to pull the screenwidth and screenheight values into a file that is read in by MMM to assign the variables. main.mmmacro1 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::0 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::0 3 | FOR | EACH | LINE IN | D:\Macro\getres.mmmacro | RUN 4 | RUN ACTION | MESSAGE PROMPT | Screen Res is %integer1%x%integer%::::0 getres.mmmacro1 | RUN ACTION | INPUT FROM FILE | INTEGER1::REFRESH::D:\Macro\inX.txt 2 | RUN ACTION | RUN VIA CMD /c | for /f "tokens=1,2 delims== skip=2" %i in ('wmic desktopmonitor get screenwidth /value') do (IF NOT "%j"=="" <NUL set /p out=%j>D:\MACRO\inX.txt) 3 | RUN ACTION | WAIT SECONDS | 2 4 | RUN ACTION | INPUT FROM FILE | INTEGER::REFRESH::D:\Macro\inY.txt 5 | RUN ACTION | RUN VIA CMD /c | for /f "tokens=1,2 delims== skip=2" %i in ('wmic desktopmonitor get screenheight /value') do (IF NOT "%j"=="" <NUL set /p out=%j>D:\MACRO\inY.txt) 6 | RUN ACTION | WAIT SECONDS | 2 OUTPUT TO FILE can be used to populate a single entry. Something like this: 1 | RUN ACTION | INPUT FROM FILE | INTEGER::REFRESH::D:\Macro\RX\INTEGER.txt 2 | RUN ACTION | OUTPUT TO FILE | D:\Macro\RX\INTEGER.txt::OVERWRITE::%INTEGER% www.turnssoft.com/conditions.html#inputfromfilewww.turnssoft.com/conditions.html#outputtofile
|
|
|
Post by zeak on Nov 29, 2018 0:07:33 GMT
1 | RUN ACTION | INPUT FROM FILE | INTEGER::REFRESH::D:\Macro\RX\INTEGER.txt 2 | RUN ACTION | OUTPUT TO FILE | D:\Macro\RX\INTEGER.txt::OVERWRITE::%INTEGER%
So if I was to do this I would require a different text file for each INTEGER that I wanted recorded. Is there a way to pull a particular INTEGER from a text file that has multiple INTEGERs in it like your previous example below.
VARS.txt INTEGER::10 INTEGER1::20 INTEGER2::30 INTEGER3::40 INTEGER4::50 STRING::Ant STRING1::Bee STRING2::Cat STRING3::Dog STRING4::%CLIPBOARD% Lets say I only wanted to update "STRING1::Bee" from this file, would that be possible? I'm just hoping to get away from having half a dozen text files required with my macro.
|
|
|
Post by Steve on Nov 29, 2018 3:37:40 GMT
Yeah if you only wanted to update STRING1=Bee then within VARS.txt you would change the value of STRING1 within the file.
1 | RUN ACTION | INPUT FROM FILE | VARIABLES::REFRESH:D:\Macro\RX\VARS.txt 2 | RUN ACTION | MESSAGE PROMPT | Value of STRING1 = %STRING1%::Value Before ::0 * | Make the change to the value within VARS.txt now and save the file. 3 | RUN ACTION | WAIT SECONDS | 5 4 | RUN ACTION | MESSAGE PROMPT | Value of STRING1 = %STRING1%::Value After ::0 VARS.txtINTEGER::10 INTEGER1::20 INTEGER2::30 INTEGER3::40 INTEGER4::50 STRING::Ant STRING1:: FrogSTRING2::Cat STRING3::Dog STRING4::%CLIPBOARD%
|
|
|
Post by zeak on Nov 29, 2018 4:23:57 GMT
Can I update the value STRING1 from Bee to Frog without having to open the text file. can I use a macro to do so?
1 | RUN ACTION | INPUT FROM FILE | VARIABLES::REFRESH:D:\Macro\RX\VARS.txt 2 | RUN ACTION | MESSAGE PROMPT | Value of STRING1 = %STRING1%::Value Before ::0 3 | RUN ACTION | DEFINE STRING VARIABLE | %STRING1%::Frog 4 | RUN ACTION | OUTPUT TO FILE | D:\Macro\RX\VARS.txt::STRING1::%string1% 5 | RUN ACTION | DEFINE STRING VARIABLE | %STRING1%::Bee * | This is just to change the variable on MMM to be different then Frog to see if the change works. 6 | RUN ACTION | INPUT FROM FILE | STRING1::REFRESH:D:\Macro\RX\VARS.txt 7 | RUN ACTION | MESSAGE PROMPT | Value of STRING1 = %STRING1%::Value After ::0
The Idea is if you could use a STRING or INTEGER was well as OVERWRITE or APPEND while performing the OUT TO FILE action. Sorry if you have trouble understanding what I am thinking as I have trouble communicating my thoughts.
|
|
|
Post by Steve on Nov 29, 2018 5:03:00 GMT
1 | RUN ACTION | OUTPUT TO FILE | D:\Macro\RX\VARS.txt::OVERWRITE::%VARIABLES% The line above will output the value of all current variables to the file VARS.txt with the correct formatting. Does this help?
|
|
|
Post by zeak on Nov 29, 2018 5:05:55 GMT
1 | RUN ACTION | OUTPUT TO FILE | D:\Macro\RX\VARS.txt::OVERWRITE::%VARIABLES% The line above will output the value of all current variables to the file VARS.txt with the correct formatting. Does this help? the issue with that is I don't wish to change the other variables, just a single one.
|
|
|
Post by Steve on Dec 3, 2018 5:23:54 GMT
VARS.txt could have a single entry. Something like: STRING1::Frog
With 1 | RUN ACTION | INPUT FROM FILE | VARIABLES::REFRESH:D:\Macro\RX\VARS.txt any changes to VARS.txt during the running macro will refresh the variable value that it is assigned to.
|
|
|
Post by cyberchipz on Apr 3, 2022 21:04:09 GMT
I have tried to use INPUT FROM FILE this and it isn't working for me. Line 16 should import the variables into the macro... the file has changed and STRING1 says TESTING WORKS I am using 8.3.3.0 - have not tested in previous versions... just needed it now. The error created just repeats the code in line 16, (NO REASON OR ANYTHING) same happens for trying to save a changed variable and overwrite it with OUTPUT TO FILE (Not shown) Bottom line; code is not IMPORTING or EXPORTING variable values to the file. (Lines 20-22 work)
1 | RUN ACTION | DEBUG | BACKGROUND COLOR::Black 2 | RUN ACTION | WAIT SECONDS | 1 3 | RUN ACTION | DEBUG | FOREGROUND COLOR::White * | Want to keep the previous Variables from another macro IOW don't want to lose them, so for testing assigning manually * | and I already tested this without the variables being assigned, and testing adding VARS to see if that caused it to fail 4 | RUN ACTION | DEFINE STRING VARIABLE | STRING::ERRHANDLER * | Defined this next variable top TESTING.. file says TESTING WORKS 5 | RUN ACTION | DEFINE STRING VARIABLE | STRING1::TESTING 6 | RUN ACTION | DEFINE STRING VARIABLE | STRING2::DebugClickCheck 7 | RUN ACTION | DEFINE STRING VARIABLE | STRING3::StopIt Normal is FALSE AUTO is TRUE SKIPPED is %SKIPPEDFLAG% 8 | RUN ACTION | DEFINE STRING VARIABLE | STRING4::NotTesting 9 | RUN ACTION | DEFINE INTEGER VARIABLE | INTEGER::0 10 | RUN ACTION | DEFINE INTEGER VARIABLE | INTEGER1::1298 11 | RUN ACTION | DEFINE INTEGER VARIABLE | INTEGER2::778 12 | RUN ACTION | DEFINE INTEGER VARIABLE | INTEGER3::0 13 | RUN ACTION | DEFINE INTEGER VARIABLE | INTEGER4::2
* | This should be code to read in the changed variables (file content is listed below 14 | RUN ACTION | MESSAGE PROMPT | String1 is %STRING1%::TESTING INPUT FROM TEXT LOCATION::0::OK 15 | RUN ACTION | INPUT FROM FILE | VARIABLES::REFRESH:C:HWFLAGS\VARS.txt 16 | RUN ACTION | WAIT SECONDS | 5 17 | RUN ACTION | MESSAGE PROMPT | String1 is %STRING1%'\n'THIS SHOULD BE - TEST WORKS::TESTING INPUT FROM TEXT LOCATION::0::OK
18 | RUN ACTION | STOP * | So I initially run each line here manually to set the variables first. * | In reality Vars already exist because I retain Variable Values macro to macro * | Change this line for testing purposes 19 | RUN ACTION | DEFINE STRING VARIABLE | STRING1::TESTING WORKS 20 | RUN ACTION | OUTPUT TO FILE | C:\HWFLAGS\VARS.txt::OVERWRITE::%VARIABLES% 21 | RUN ACTION | STOP
Pretty sure I didn't need line 16 but added anyway... just because. Lines 11 and 12 works... and creates the file with all the variables Below
STRING::ERRHANDLER
STRING1::TEST WORKS
STRING2::DebugClickCheck
STRING3::StopIt Normal is FALSE AUTO is TRUE SKIPPED is %SKIPPEDFLAG%
STRING4::NotTesting
INTEGER::0
INTEGER1::1298
INTEGER2::778
INTEGER3::0
INTEGER4::2
|
|
|
Post by Steve on Apr 4, 2022 22:36:15 GMT
Hi cyberchipz I can't see where you could be going wrong. It looks ok to me. Is the MMM internal event log giving you any feedback that might help? Have a look at this example based off your STRING and INTEGER variable. You should be able to replicate this by pasting the code into MMM:
* | ############################# * | Clear all vars * | ############################# 1 | RUN ACTION | DEFINE STRING VARIABLE | FARM::Chicken 2 | RUN ACTION | DEFINE BOOLEAN VARIABLE | STATUS::FALSE 3 | RUN ACTION | DEFINE INTEGER VARIABLE | COUNT::0 4 | RUN ACTION | DEFINE STRING VARIABLE | STRING::NUL 5 | RUN ACTION | DEFINE STRING VARIABLE | STRING1::NUL 6 | RUN ACTION | DEFINE STRING VARIABLE | STRING2::NUL 7 | RUN ACTION | DEFINE STRING VARIABLE | STRING3::NUL 8 | RUN ACTION | DEFINE STRING VARIABLE | STRING4::NUL 9 | RUN ACTION | DEFINE INTEGER VARIABLE | INTEGER::0 10 | RUN ACTION | DEFINE INTEGER VARIABLE | INTEGER1::0 11 | RUN ACTION | DEFINE INTEGER VARIABLE | INTEGER2::0 12 | RUN ACTION | DEFINE INTEGER VARIABLE | INTEGER3::0 13 | RUN ACTION | DEFINE INTEGER VARIABLE | INTEGER4::0 * | ############################# * | Output all vars prior to input from file * | ############################# 14 | RUN ACTION | MESSAGE PROMPT | %STRING%'\n'%STRING1%'\n'%STRING2%'\n'%STRING3%'\n'%STRING4%'\n'%INTEGER%'\n'%INTEGER1%'\n'%INTEGER2%'\n'%INTEGER3%'\n'%INTEGER4%'\n' 15 | RUN ACTION | MESSAGE PROMPT | %FARM%'\n'%STATUS%'\n'%COUNT%::Farm - Status - Count * | ############################# * | input from file from input1.txt * | ############################# 16 | RUN ACTION | INPUT FROM FILE | VARIABLES::NO_REFRESH::D:\Dropbox\Macro\File\input1.txt * | ############################# * | output all vars post input from file * | ############################# 17 | RUN ACTION | MESSAGE PROMPT | %STRING%'\n'%STRING1%'\n'%STRING2%'\n'%STRING3%'\n'%STRING4%'\n'%INTEGER%'\n'%INTEGER1%'\n'%INTEGER2%'\n'%INTEGER3%'\n'%INTEGER4%::Strings and Integers 18 | RUN ACTION | MESSAGE PROMPT | %FARM%'\n'%STATUS%'\n'%COUNT%::Farm - Status - Count input1.txtFARM::Goat STATUS::False COUNT::2 STRING::ERRHANDLER STRING1::TEST WORKS STRING2::DebugClickCheck STRING3::StopIt Normal is FALSE AUTO is TRUE SKIPPED is %SKIPPEDFLAG% STRING4::NotTestingNo INTEGER::1 INTEGER1::1298000 INTEGER2::77800000 INTEGER3::10000000 INTEGER4::200000
|
|
|
Post by cyberchipz on Apr 5, 2022 14:16:51 GMT
OH MY! I feel like such a doof... shaking my head.... line 15 of my code is missing a colon... and backslash after C: (sigh).... I'm just going to fall back on... my hand injury has me having to pay so much attention to my typing... that when I edited the path, I botched it up and didn't see it. Thank you so much... I'll just say that having code I know works to go from.... sure makes a big difference in my expectations... Naturally, I had to change the path in your code; but, I didn't mess up this time when I changed it. I was going to write... saving the whole file and input that would have been a good enough workaround... I'd have used it; but, everything is working now... and I appreciate this so much... thanks for bearing with me. typo's ... a coder's worst enemy. (sigh). Thanks again Steve... All of my previous and new, from you, code is all working now! :-) PS: For what it is worth; the MMM internal event log only repeated the line with the error; but with the missing colon, and missing backslash... it had nothing to say about the line... it did not pick up on the syntax error; but, then I don't expect it would. ibb.co/sCCnGkJ image of error log.
|
|