tibabs
Junior Member
Posts: 13
|
Post by tibabs on Jan 5, 2019 13:10:03 GMT
In a previous thread (reading a csv file) I found a solution to bypass the limit of 4 %STRING% variables, but I have a trouble.
Could you explain me how the time of execution of a batch is managed by MMM. It generate me troubles because my bat file (RUN VIA CMD /C) is not ended before my next command (INPUT FROM FILE) !!!
Present in a simple manner the problem is :
15 | RUN ACTION | MESSAGE PROMPT | %TIME%
16 | RUN ACTION | RUN VIA CMD /C | testTO.bat
17 | RUN ACTION | MESSAGE PROMPT | %TIME%
with testTO.bat ========== echo %time%
timeout /t 5
echo %time%
It does not wait the end of the script to go to the next command line !!! It is the same with the RUN VIA CMD /K command.
Regards
|
|
|
Post by Johnc on Jan 5, 2019 20:31:33 GMT
RUN VIA CMD will run asynchronously once u fire it off. MMM will not wait for it to finish before it continues to the next line.
If u want MMM to wait for the RUN VIA CMD to finish before it goes on to the next MMM line, u need to do something like the following:
1 | RUN ACTION | | | | RUN VIA CMD /C | title=runscript & C:\Program_Portable\mmm\script01 2 | RUN ACTION | | | | WAIT SECONDS | 1 3 | IF | WINDOW TITLE | runscript | NOT EXIST | CONTINUE 4 | RUN ACTION | | | | MESSAGE PROMPT | %CLIPBOARD%::clip
|
|
tibabs
Junior Member
Posts: 13
|
Post by tibabs on Jan 5, 2019 22:38:46 GMT
Thank you,
I understand you have to wait some seconds ... but how many if your process last from 1 to 10 seconds. It culd becomes a waste of time.
It is a pity that it is not available to choose Synchronou or asynchronous mode. I solved my problem another way. In fact, because I have to feed forms on web, I detach the preparation of my MMM_parms.txt (STRINGx:: format) to the INPUT FROM FILE.
Instead of something like - feed forms or clicking on menus/sub menus - csv2Parms.bat => MMM_parms.txt (csv data #1 to #4) - INPUT FROM FILE MMM_parms.txt - use of %STRING1% to %STRING4% (corresponding to csv data #1 to #4) - feed forms ... - csv2Parms.bat => MMM_parms.txt (csv data #5 to #8) - INPUT FROM FILE MMM_parms.txt - use of %STRING1% to %STRING4% (corresponding to csv data #5 to #8) - feed forms ...
I've made something like this - csv2Parms.bat => MMM_parms.txt (csv data #1 to #4) - feed forms or clicking on menus/sub menus ==> these operations take time - INPUT FROM FILE MMM_parms.txt (the CMD BATCH is over since a long time) - csv2Parms.bat => MMM_parms.txt (csv data #5 to #8) - use of %STRING1% to %STRING4% (corresponding to csv data #1 to #4) - feed forms ... - INPUT FROM FILE MMM_parms.txt (the CMD BATCH is done since a long time) - use of %STRING1% to %STRING4% (corresponding to csv data #5 to #8) - feed forms ...
It works.
Regards, Thierry
|
|
|
Post by Steve on Jan 6, 2019 4:23:54 GMT
Hi Thierry, This example will wait for the batch file to finish before continuing to the next line:
runloopmacro.mmmacro
1 | RUN ACTION | MESSAGE PROMPT | Prior to batch file::%time%::0 2 | RUN ACTION | RUN PROGRAM | D:\Macro\OUTPUT\loop.bat 3 | RUN ACTION | WAIT SECONDS | 1 4 | IF | WINDOW TITLE | mybatchfile | NOT EXIST | CONTINUE 5 | RUN ACTION | MESSAGE PROMPT | After batch file::%time%::0 loop.bat@echo off :PRE color 0a set intI=0 TITLE=mybatchfile
:HEAD cls set /a intI=intI+1
:MAIN echo %intI% of 10 ping -n 2 127.0.0.1>nul if "%intI%"=="10" (EXIT) else (GOTO HEAD)
|
|
|
Post by Johnc on Jan 6, 2019 5:35:08 GMT
"I understand you have to wait some seconds ... but how many if your process last from 1 to 10 seconds. It culd becomes a waste of time."
I think you have misunderstood the fixed 1 sec delay Thierry. The magic is not there. It is in next line:
3 | IF | WINDOW TITLE | runscript | NOT EXIST | CONTINUE
This line will wait for however long it will take for the batch file (runscript) to finish, be it 1 sec or 3 secs or 10 secs. So the wait time is automatic. No time will be wasted. Cheers.
|
|
tibabs
Junior Member
Posts: 13
|
Post by tibabs on Jan 6, 2019 16:38:48 GMT
Hi Johnc, thanks for your implication. It does not work at home !!! even with your script !!! I have the After messagebox as the black cmd windows is still running !!! Maybe do I have a trouble on my installation so I've tried to uninstall as you suggest in an another thread but I miss too !!! Even in Administrator mode, i've got the following message Maye it could explain why the new version sent by Steeve does not work. I have no 99 strings !! Another question. If it's run correcly, what is the need to sleep 1 second previously ? Regards
|
|
|
Post by Johnc on Jan 6, 2019 17:44:25 GMT
Well I guess Steve will have to help you on this one as I am just another user lol! I am guessing the 1 sec delay is there to make sure the script has started to run before you check its title. Not having the %STRING99% variable??? Strange! Maybe u have got an incorrect version?? My MMM beta version has it!
|
|
|
Post by Steve on Jan 6, 2019 22:10:18 GMT
Hi Thierry, Paste in your macro and I will have a look. By the look of your screenshot I can guess the problem is the window title of your batch file. Have a look here ( www.turnssoft.com/conditions.html) for a deeper understanding on conditions. Check out the WindowTitle condition. The version you have does have 99 string and integer variables. Perhaps you are not using them correctly in your implementation. I'll check out your macro when you post it through and get back to you. Regards, Steve.
|
|
tibabs
Junior Member
Posts: 13
|
Post by tibabs on Jan 6, 2019 23:44:41 GMT
Hi,
As explain, I try to uninstall ... finaly I've succeed with using regedit. For the script, you've got it (mine and Johnc too). Johnc's script is now running. Magic computer science ;-)
Anyway I ran the 99 version ... without succed (99 variables are not existing in the variables tab !!). Should they not be ? Tommorow, I will do a fresh install on another computer ... I take you in touch ;-)
Excuse for my poor english ;-)
|
|
|
Post by Johnc on Jan 7, 2019 0:47:00 GMT
(99 variables are not existing in the variables tab !!)
Don't worry about this. Not all of them r in the variable tab. Just make use of them in the Macro. I tried %STRING99% and it is working despite the fact that it is not visible on the tab.
|
|
|
Post by Steve on Jan 7, 2019 0:50:25 GMT
Yep all 100 variables are not listed in the variables tab but they are available.
|
|
tibabs
Junior Member
Posts: 13
|
Post by tibabs on Jan 7, 2019 15:08:26 GMT
Hi,
I can access to more than 4 strings but not thanks to INPUT FROM FILE (what is my problem/need to load csv files). No %STRING7% set.
1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING31%::StartMacro1 2 | RUN ACTION | INPUT FROM FILE | VARIABLES::NO_REFRESH::Vars.txt 3 | RUN ACTION | MESSAGE PROMPT | ST1 from Vars.txt = %STRING1% , ST7 from Vars.txt = %STRING7% , ST31 from DEFINE = %STRING31%
Give ==> ST1 from Vars.txt = ST1 , ST7 from Vars.txt = , ST31 from DEFINE = StartMacro1
with Vars.txt like this
STRING1::ST1 STRING2::ST2 STRING3::ST3 STRING4::ST4 STRING5::ST5 STRING6::ST6 STRING7::ST7 STRING8::ST8
NB : It's done on a fresh install !!!
|
|
|
Post by Steve on Jan 7, 2019 21:48:08 GMT
Thanks for pointing that out Thierry. Looks like the input from file needs updating for the new variable addition with the latest beta. I'll update that and get a new beta out.
|
|
tibabs
Junior Member
Posts: 13
|
Post by tibabs on Jan 7, 2019 23:02:03 GMT
Yeesssssssss. I've got a real bug ;-) It's changing for my previous mis-use of the soft ;-)
Regards.
|
|