12-04-2005, 10:28 PM
NOTE: This does not work with files of QM 2.4.0 and later.
Try this.
Member function str.GetMacroFromFile
Function RunMacroFromFile
Function RunFunctionFromFile
If file or macro not found, each of these functions throws error (macro ends).
This macro shows a macro from a file:
Try this.
Member function str.GetMacroFromFile
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
;/
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
;/
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: