5 Replies Latest reply: Jul 13, 2009 8:02 PM by Rob Wunderlich RSS

    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



        • How to debug a macro crashing in script
          Stephen Redmond

          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

           

            • How to debug a macro crashing in script
              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

                • How to debug a macro crashing in script
                  Rob Wunderlich

                  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

                   

              • How to debug a macro crashing in script

                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.