Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to debug a macro crashing in script

Hello

For general understanding I have writen a macro which is to be executed at several locations.
My macros name is TestMyFunction.

If I click on a textbox with my macro configured on the action "execute macro", all is running fine.

But when I execute the macro in the script, qlikview closes without any trace.
Here the script code
let Dummy1 = TestMyFunction();

Here the macro:
function TestMyFunction
set ActQvDoc = ActiveDocument
dummy = ActQvDoc.Variables("UserNameOs").SetContent ("Hallo4", true)
TestMyFunction = "Hallo1"
end function



Now how can I debug such a case when QlikView is disappearing as soon as I execute the script?

Thank you



5 Replies
stephencredmond
Luminary Alumni
Luminary Alumni

Hi,

I don't believe that you can interact with the ActiveDocument like this from within the script. There have been restrictions on it in recent versions.

What, exactly, are you trying to achieve?

Stephen

Not applicable
Author

Hi,

you can modify the function as and then call this on a Button click

let Dummy1 = TestMyFunction();

Here the macro:
function TestMyFunction
set ActQvDoc = ActiveDocument
dummy = ActQvDoc.Variables("UserNameOs").SetContent ("Hallo4", true)

Msgbox dummy 'This will give you value of Variable


TestMyFunction = dummy

end function

Also there is a Debug button given in Macro editor. you can use that.

Not applicable
Author

Hello Stephen
I'm working with version 9.00.7119.4, Personal Edition for these tests.
I would like to set the value of a self defined variable, in this case "UserNameOs".
But as I see in the script I have to use the statement:
Set UserNameOs = "AValue";
What a pity.
Usualy I use macros (functions) to avoid redundancies, but obviously in the macro I can't access a variable in the same way as in the script.
So the ability to define variables and to write macros is in a way obsolete.
Thanks for help
Valerio

Not applicable
Author

Hello

This method do not work for debugging as QV is obviously dying at the statement

dummy = ActQvDoc.Variables("UserNameOs").SetContent ("Hallo4", true)

Thanks Valerio

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

One way for a macro to set a variable from in a load script, without using ActiveDocument:

LET UserNameOs=TestMyFunction();
where the macro is:
Function TestMyFunction
TestMyFunction = "foo"
End Function


If you need to read a variable value in the macro, you'll have to pass it as a parameter:

LET vX = 1;
LET vY = addTwo($(vX);
where the macro is:
Function addTwo (input)
addTwo = input + 2
End Function


-Rob