/ Forums / Advansys Formativ / Creating Solutions with Formativ / When are variables in an applet unloaded?

  • Creator
    Topic
  • #4277
    jcromwijk
    Participant

      When are variables in an applet unloaded?
      – at the end of sub Main?
      OR
      – when closing groupwise

    • Author
      Replies
    • #7690
      Support 1
      Participant

        Thank you for your enquiry.

        In the following I have assumed that by “unloaded” you mean the memory used by a variable is deallocated or returned to the system. If this is not correct, please describe your technical requirement.

        The answer to your question depends on how the variables are used in an applet.

        The Formativ language is VBScript with extensions for working with the GroupWise APIs. A VBScript script/applet is executed by the Windows Scripting Host, and VBScript variables have the type Variant. The Variant type supports a number of subtypes, eg. integer, string, Boolean, Object (which could be a COM/OLE object). See the VBScript documentation for more information.

        In general, variables are deallocated when they go out of scope. Here are some example cases:

        • Local variable, ie. a variable declared inside a function/subroutine. Deallocation is automatic on exit from the function/subroutine.
        • Global variable, ie. a variable declared outside all functions/subroutines/classes. Deallocation is automatic on termination of the script.
        • Class variable, ie. a variable declared as a class member. Deallocation is automatic on deallocating an instance of the class.
        • A variable that is assigned using the set operator refers to an Object. More than one variable can refer to a single Object. Assigning nothing to the variable decrements the reference count for the Object, which will be deallocated when the count equals zero. Otherwise, the reference count is decremented automatically when the variable goes out of scope.
        • Formativ provides Utilities.TransferData which stores a string outside the scope of an applet. One applet can write to TransferData and another applet can read from TransferData. Its value is available for an entire GroupWise session: TransferData is deallocated when GroupWise shuts down. See the Formativ Language Guide for more information.

        I hope this helps.

        Regards,
        Advansys Support

        #7694
        jcromwijk
        Participant

          Thanks for your good explanation.
          I have an question raised by your answer

          quote:


          Deallocation is automatic on termination of the script.


          When is the termination of the script?
          – At the end of the sub main
          OR
          – When closing GW

          Greetings,
          Jan Cromwijk

          #7693
          Support 1
          Participant

            A script terminates at the end of sub Main.

            Regards,
            Advansys Support

            #7692
            jcromwijk
            Participant

              Thanks

              I will review the scopes of my variables.

              #7691
              jcromwijk
              Participant

                quote:


                Originally posted by Support 1:
                A script terminates at the end of sub Main.


                Are the used forms from the applet also unloaded at that time?

                Greetings,
                Jan Cromwijk

                #7689
                Support 1
                Participant

                  quote:


                  Are the used forms from the applet also unloaded at that time?


                  Yes, an applet’s forms are deallocated when the applet terminates.

                  Regards,
                  Advansys Support

                Viewing 6 replies - 1 through 6 (of 6 total)
                • You must be logged in to reply to this topic.