paul Posted August 19, 2009 Report Share Posted August 19, 2009 When running a macro with MeProc.exe, parameters must be passed using the /A and /V arguments, as in: "C:\Program Files\Macro Express Pro\MeProc.exe", /AMyMacro /VT99:abc /VT98:def The macro MyMacro must, in this case, do a Restore Text Variables in order to set %t[98]% to "def" and %t[99]% to "abc". Unfortunately the Restore Text Variables command in the latest release of MEP is very slow, at least on my machine. It has always operated more or less instantaneously, but now takes 4 seconds! I have therefore decided to adopt a new approach (I have never much liked the Restore Variable commands anyway because of how they affect other unrelated macros - unless you go to the trouble of clearing all text variables and then saving them). For those macros that require parameters I shall store one text file for each macro (using the macro name as part of the text file name): nn,tt where nn is the index number of the %t% array into which I store the value tt. First I copy the relevant macro text file to "C:\MacrosPro\MacroParameters.txt", then: If File Exists: "C:\MacrosPro\MacroParameters.txt" ASCII File Begin Process: "C:\MacrosPro\MacroParameters.txt" (Comma Delimited Text (.csv)) -- into array %tContents% Variable Set String %t[%tContents[1]%]% to "%tContents[2]%" ASCII File End Process Delete File/Files: "C:\MacrosPro\MacroParameters.txt" End If This works very well, requires no Restore or Save commands , and leaves no side-effects. Quote Link to comment Share on other sites More sharing options...
Cory Posted August 26, 2009 Report Share Posted August 26, 2009 I don't know if you recall but I once said here that with the new variable system I see no need whatsoever for Variable Save/Restore. Some made a couple of mentions of rare cases where it might be useful but I firmly believe that 99% of the time if a person is using Variable Restore they're not doing it the best way regardless of performance issues. IMHO it's a command left in for reverse compatibility and should be eradicated at every opportunity. And for these reasons I would like to see any work on it to be a back burner item for ISS. In this case however why don't you simply not use the command line pass and just store the values in the reg and have the first couple of lines in the macro read those values in? Quote Link to comment Share on other sites More sharing options...
paul Posted August 26, 2009 Author Report Share Posted August 26, 2009 In this case however why don't you simply not use the command line pass and just store the values in the reg and have the first couple of lines in the macro read those values in? If my macro uses the Variable Restore command or the alternative approach I described earlier, then the macro doesn't need to "know" anything specific. In other words, it performs a process (Variable Restore or the read of that generic C:\MacrosPro\MacroParameters.txt file); and the logic of the process remains static across all macros. Whether the process causes variables to become initialized with specific values is determined by the calling process, i.e. whether any values have been passed in with the /VT parameters, or if the C:\MacrosPro\MacroParameters.txt file exists - nothing more. Forcing a macro to know how many parameters to read and where from introduces dependencies where none existed before. I prefer my macros to be as robustly independent as possible. 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.