7 Replies Latest reply: Jan 9, 2013 4:53 PM by Marina Alvarez Ruiz RSS

    Assign a variable in the Load script via Macro.. possible?

      For the sake of debugging, I've been trying to use a JScript macro function to pause script execution, and provide me with a status message. In theory, it should work fine.. but for some reason, the Load script skips over evaluation of my macro function as if I just put '' there instead.

      Here's the JScript Macro (beware, I use interesting syntax)

       


      function Say (strMessage)
      { return ActiveDocument
      .GetApplication()
      .InputBox(strMessage);}


       

      And then the following load script statement:

       


      LET nil = Say('Loop 1 Entered');


      The end result at every attempt has been that nil is defined as a variable, but has no value. The InputBox function does not successfully pop up an input box.

      When testing inside the Module editor, the function works exactly as intended.

      Any help?

        • Assign a variable in the Load script via Macro.. possible?
          Rob Wunderlich

          I'm not sure why it doesn't work, but it's an unusual way to generate the message. The more direct route would be to call the jscript function window.alert() or window.prompt() and not call back into the Qlikview API.

          You can also do this directly in the script without any macro at all using QV functions.

          LET nil = msgbox('Loop 1 Entered');

          or

          LET nil = input('Loop 1 Entered');

          I realize I may not be understanding all of your requirements, so post back if I'm missing something.

          -Rob

            • Assign a variable in the Load script via Macro.. possible?

              Rob,

              Thank you for the help. For my current needs, the native Qlikview MsgBox() and Input() functions will suffice. However, I still have the concern about calling Macro code from within the load script.

              With regards to window.alert() and window.prompt(): the window object and it's methods aren't available inside of the Qlikview scripting client. That's why the qvlib was created, to make available the functionality that ends up missing.

              The overall reason I'd like to know if this is actually possible is that I'd like to write a script pre-processor in order to reduce the overall script footprint in our applications. I could always trigger a macro on an event, I suppose. But the reference manual alludes that the functionality should be available within the script..

              -Alex

                • Assign a variable in the Load script via Macro.. possible?
                  Rob Wunderlich

                  There appears to be a limitation in using functions that write to the window in the reload case. However, I frequently use macro functions that return values to the script with no problems. Do you specifically need window functions?

                  -Rob

                    • Assign a variable in the Load script via Macro.. possible?

                       


                      Rob Wunderlich wrote:
                      There appears to be a limitation in using functions that write to the window in the reload case. However, I frequently use macro functions that return values to the script with no problems. Do you specifically need window functions?
                      -Rob<div></div>


                      The only time I suspect I'll need window functions is to break execution, and allow me to specify an alternate code path (or supply a code path) for rapid testing and development.

                      Most of what I intend to do is for automated profiling, pre-compilation, and potentially to write my own EDSL.

                      I'll try out the suggestion of not using windowed functions, and see if it works as expected. For a bit I was worried that it might just be a bug in the way Qlikview works on top of Windows 7. :)

                      Thanks for the help!

                      -Alex

                  • Assign a variable in the Load script via Macro.. possible?
                    rajesh.ks

                    Hi rob,

                    I want to pass the selected value from the list to a script via a macro. Can you help me out?

                     

                    Thanks in Advance