Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run another file consisting multiple macros
#1
The following:

run "C:\QM Macros\MyMac"


Opens the file for me, but how to I tell it to play a specific macro in the file? There are multiple macros in it.

Thanks!
#2
Usually QM macro list files are not used for this purpose. What is the reason you want to run a macro from another file, not from main file?
#3
I am trying to control the size of the files. They are getting pretty large.

The person who was in-charge previous to me did not do a great job. We have functions with the same names but does not do similar things.

That is why I have not been importing at all.

Is this not possible?

I used shutdown -6 then the run. It does open the file, but I dont know how to tell it to play certain macros in different folders.
#4
NOTE: This does not work with files of QM 2.4.0 and later.

Try this.

Member function str.GetMacroFromFile
Code:
Copy      Help
function $qml_file $macro_name

;Extracts text of a macro (or of an item of other type) from a QM macro list file (qml).

;EXAMPLE
;str s.GetMacroFromFile("test.qml" "Macro2")
;RunTextAsMacro s



str s.getfile(qml_file)
str sm.from("[]  " macro_name " ")
sm[2]=0; sm[3]=0; sm[sm.len-1]=0
int i j=findb(s sm sm.len); if(j<0) goto e
i=findb(s "[]" 2 j+sm.len)+2; if(i<2) goto e

this.get(s i len(s+i)-2)
ret
;e
end "macro not found"

Function RunMacroFromFile
Code:
Copy      Help
;/
function $qml_file $macro_name

;Runs a macro from other QM macro list file. Does not check
;whether it is actually macro. That is, gets first item that
;matches macro_name. It can be even folder.
;Two macros cannot run simultaneously. If this function is
;called from a macro, the extracted macro runs when the
;caller macro ends. If called from a function, runs
;simultaneously.


;EXAMPLE
;RunMacroFromFile("test.qml" "Macro2")



str s.GetMacroFromFile(qml_file macro_name)
RunTextAsMacro s
err+ end _error

Function RunFunctionFromFile
Code:
Copy      Help
;/
function# $qml_file $function_name [~a1] [~a2] [~a3] [~a4]

;Runs executable function from other QM macro list file.
;Does not check whether it is actually function. That is,
;gets first item that matches function_name. It can be even
;folder.
;The extracted function runs asynchronously. This function
;returns thread handle. If caller wants to wait until the
;function ends, it can use the handle with the wait function.


;EXAMPLE
;wait 0 H RunFunctionFromFile("test.qml" "Function2")



str s.GetMacroFromFile(qml_file function_name)
ret RunTextAsFunction(s a1 a2 a3 a4)
err+ end _error

If file or macro not found, each of these functions throws error (macro ends).

This macro shows a macro from a file:
Code:
Copy      Help
str s.GetMacroFromFile("$qm$\dialogs.qml" "DE_wm_size")
ShowText "" s 0 2
#5
I forgot to mention I am currently using 2.1.4.
#6
What is not working (I cannot quickly test)?
#7
Well I copied the codes and made 2 functions: GetMacroFromFile and RunMacroFromFile.


When compiling GetMacroFromFile, it gave a compiler error "this" can be used only in member function."

The compiling RunMacroFromFile, compiler error is "Unknown member."
#8
Delete GetMacroFromFile function, create new member function, name it exactly str.GetMacroFromFile, and paste the code.
#9
Great, its getting there. I kinda miss the MEMBER part lol.

Problem is, the macro I am running from another file is using other Functions from that file. It did start the macro but stopped because the functions do not exists in the current macro.

Thanks so much for your help.
#10
This is really problem.
#11
Yes I know, lol.

When I tried the run and mac commands, I was able to open the file but it does not run the macro. I guess since the original macro was already closed, that is why.


Is it possible to DISABLE a function? I was able to find dis command but it is only for triggers. I imported the macro and everything seems ok except, I need to disable one function to make it work.
#12
sounds like you need to take the day and rebuild this guy's names for the macros and put them into your list.
#13
Rename or delete all items with duplicate names. Especially functions. Only folders can have same names. Don't rename or delete items in System folder.

If there are to functions with same name, one of them is disabled, and error message probably is displayed.

To disable a function, convert it to macro: in Properties, select Macro where now you see Function.

Finally, restart QM.
#14
Would this approach also help me with files that are longer than 32K characters.

I have one macro which I made in Word pad but it happens to have more than 32k characters, so in the UI for pasting the macro it bombs. What should I do?
#15
Depends on what the macro should do. If it should paste the text, save the text to a file, and let the macro get the text from the file. If the text is QM code, divide it into several functions.


_s.getfile("$desktop$\test.txt")
outp _s


Attached Files Image(s)
   
#16
My macro needs to do the following:
key "MM" T "6999" T "ABC123455"
1
key F10
1
key F10
1
key "LO" T "6777" T "ABC123456"
1
key F10
1
key F10
1
repetitively, these numbers are in an excel sheet. I already have the macro edited into multiple <32k files but QM does not run each statement in order, it keeps on running the last file only. This is similar post as in a previous post. Thanks.
#17
Now all this data is stored in macro. Do you really need this? Maybe better would be to get it directly from the worksheet? Macro could do it programmatically, without keys, and, if needed, even without showing Excel. Then the macro could repeat for each row. Also is possible to export the worksheet to a csv file, and the macro can parse it.


Forum Jump:


Users browsing this thread: 2 Guest(s)