Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pausing a Function/Macro
#1
I have a main macro which starts 2 functions. One of the function is like the "traffic control" of what is going on in the document that is being cleaned up. This function is triggered when a certain window comes up. In this case, if a search fails in the document, a message box comes up saying "Word Not Found." When this happens, I need to pause the main macro, do other things in the function, then let the main macro resume.

Would this be possible? I am not sure if I'm explaining this well at all.

Thank you!
#2
Simply pausing macro from outside (manually or by an external function) is not possible. It is possible only if the macro itself checks for some condition. For example, if the macro executes some code repeatedly, it can check a global variable, and, if the variable says to wait, it waits.

Example
In macro:
Code:
Copy      Help
int+ g_pauseMacroX
rep
,if(g_pauseMacroX) wait 0 -V g_pauseMacroX
,;...

In function:
Code:
Copy      Help
int+ g_pauseMacroX
g_pauseMacroX=1
;...
g_pauseMacroX=0
#3
Other way - instead of using separate window-triggered function, do all it in the macro. Example:

Code:
Copy      Help
;...
;at this time, a window "Word Not Found" may appear or not

wait 1 WA "Word Not Found"; err goto Continue ;;wait for the window. If it does not appear during 1 s, go to label Continue
;place here the code that should be executed in case the window appears


;Continue
;...
#4
Actually, the first solution worked out for the best. Problem I am having now is that, it is better for the variable to return 2 values instead of a 0. For example, if 1, do this, if 2, do something else. -V only waits for 0 Cry
#5
In macro:
Code:
Copy      Help
int+ g_pauseMacroX=1
rep
,if(g_pauseMacroX=0)
,,sel wait(0 V g_pauseMacroX)
,,,case 1
,,,;...
,,,case 2
,,,;...
,;...

In function:
Code:
Copy      Help
int+ g_pauseMacroX=0
;...
g_pauseMacroX=1 ;;or 2, etc
#6
This is weird, I'm not sure what I did but all of sudden I am receiving an error message: Exception (RT) in : exception in destructors of local variables.

I don't know where to look for this error, have not seen it before.
#7
Please post the macro.
#8
Gintaras Wrote:Simply pausing macro from outside (manually or by an external function) is not possible. It is possible only if the macro itself checks for some condition. For example, if the macro executes some code repeatedly, it can check a global variable, and, if the variable says to wait, it waits.

Example
In macro:
Code:
Copy      Help
int+ g_pauseMacroX
rep
,if(g_pauseMacroX) wait 0 -V g_pauseMacroX
,;...

In function:
Code:
Copy      Help
int+ g_pauseMacroX
g_pauseMacroX=1
;...
g_pauseMacroX=0





I used the above example. What does that error mean? Maybe if I know I can start looking which is giving me the error, the macro or the function.
#9
Exception (RT) in HereShouldBeMacroName: ...

This error is possible in macros or functions where are incorrectly used variables of composite types. These types are str, ARRAY, VARIANT, BSTR, interface pointers, and user-defined types containing these types. When the macro or function exits, QM frees memory associated with variables of composite types. If a variables contains invalid pointer, may occur exception (in best case) or data corruption.

Example:

str s
s.lpstr=11111111
;or
s.lpstr="a"

When leaving function, QM tries to free s.lpstr. It contains invalid pointer, and therefore exception may occur.

Try to restart QM.[/quote]
#10
There is really nothing odd from what I see in the macro or function.

When you said data corruption, do you mean the macro file itself? If it is, how do I fix it?
#11
Quote:When you said data corruption, do you mean the macro file itself?

File data corruption cannot be the reason of this exception. Either some macro is incorrectly programmed, or it is a QM bug. If you can send me your macro list file, or that part of file, I'll see what is wrong.
#12
Someone edited the file, unfortunately.

shutdown -5 was added. I have never used shutdown before so I'm sure I didn't do it. After removing that line, the file is working again.

Thank you very much!


Forum Jump:


Users browsing this thread: 1 Guest(s)