|
Post by oneurt on Mar 26, 2020 18:33:11 GMT
Hi, I couldn't come up with a good subject line, but I was looking through the INPUT to file examples, but is there a way to have STRING loop through my input.txt file and have its variable defined for each new line?
Just an example:
my input.txt is: blue purple green
I want STRING to first be defined with blue, but then in the loop of my macro I would like String to be declared as purple in the next iteration of my loop.
Is this possible?
Sorry I don't have any code.
|
|
|
Post by zeak on Mar 26, 2020 21:53:18 GMT
Hi Oneurt, First off, welcome to the forum. So my question is how important is it that only the one string gets updated? Is there a way you could work with multiple strings? Because the ACTION, INPUT FROM FILE lets you input all the lines into MMM. 1 | RUN ACTION | INPUT FROM FILE | VARIABLES::NO_REFRESH::C:\Users\Name\Documents\Calculators\Macros\input.txt SteveBut this does beg the question, is it possible to tell MMM which line to get the string value from. 1 | RUN ACTION | INPUT FROM FILE | STRING::NO_REFRESH::1::C:\Users\Name\Documents\Calculators\Macros\input.txt After NO_REFRESH I have the number 1 representing to look at the first line of the text file. 1 | RUN ACTION | INPUT FROM FILE | STRING::NO_REFRESH::%INTEGER3%::C:\Users\Name\Documents\Calculators\Macros\input.txt or if you could use an INTEGER instead then you could easily control the line you wish to look at.
|
|
|
Post by Steve on Mar 28, 2020 2:59:58 GMT
I think this is what your after... The FOR EACH LINE IN FILE condition should do the trick: 1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::red * | FOR_EACH 2 | FOR | EACH | LINE IN | D:\Macro\INPUT\loopcount.txt | DO 3 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::%LINE% 4 | RUN ACTION | MESSAGE PROMPT | STRING=%STRING%:: Value of STRING::1 5 | FOR | NEXT
|
|
|
Post by Steve on Mar 28, 2020 3:46:48 GMT
Steve But this does beg the question, is it possible to tell MMM which line to get the string value from. 1 | RUN ACTION | INPUT FROM FILE | STRING::NO_REFRESH::1::C:\Users\Name\Documents\Calculators\Macros\input.txt After NO_REFRESH I have the number 1 representing to look at the first line of the text file. 1 | RUN ACTION | INPUT FROM FILE | STRING::NO_REFRESH::%INTEGER3%::C:\Users\Name\Documents\Calculators\Macros\input.txt or if you could use an INTEGER instead then you could easily control the line you wish to look at. Hi Zeak, Yes this can be done with INPUT FROM FILE already. Check out the examples here www.turnssoft.com/conditions.html#inputfromfile that read like this: Consider the following VARIABLES example: 1 | RUN ACTION | INPUT FROM FILE | VARIABLES::REFRESH::D:\Macro\RX\INPUT.txt 2 | RUN ACTION | MESSAGE PROMPT | Value of STRING: %string%::String Value
INPUT.txt STRING::Ants STRING1::Bee
This reads INPUT FROM FILE all VARIABLES declared in D:\Macro\RX\INPUT.txt and monitor the the file for changes (REFRESH). Line 2 runs a MESSAGE PROMPT for the value of %string%. INPUT.txt declares the value of STRING to be Ants.
Consider the following single variable INTEGER example: 1 | RUN ACTION | INPUT FROM FILE | INTEGER::NO_REFRESH::D:\Macro\RX\INPUT.txt 2 | RUN ACTION | MESSAGE PROMPT | Value of INTEGER: %integer%::Integer Value
INPUT.txt 1000
This reads INPUT FROM FILE to the variable INTEGER declared in D:\Macro\RX\INPUT.txt and do not monitor
|
|
|
Post by oneurt on Mar 30, 2020 21:54:09 GMT
I think this is what your after... The FOR EACH LINE IN FILE condition should do the trick: 1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::red * | FOR_EACH 2 | FOR | EACH | LINE IN | D:\Macro\INPUT\loopcount.txt | DO 3 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::%LINE% 4 | RUN ACTION | MESSAGE PROMPT | STRING=%STRING%:: Value of STRING::1 5 | FOR | NEXT HI Steve, Thanks for the reply, this is what I was looking for as I can expand on this example for my macro.
|
|