1 Reply Latest reply on Jun 2, 2009 8:32 PM by Kuz

    Issue with checking condition of a global variable

      Hi,

      I'm writing a VBScript that checks to see if a global variable is already set.  If the variable isn't set then I want to assign an ADODB object to it.  If it is set I want to leave it alone.

      The issue that I'm having is that the check is always false.  I don't know how to clear all the global variables.  I've tried stopping and starting the service but that doesn't seem to do it.  I have no other actions that use global variables.  I'm not sure if it's me, the code, or Kiwi that's the issue here.

      Code:

      If VarType(Fields.VarGlobal02) <> 9 Then '{Global command - Not assigned yet} 

      Set thecommand = CreateObject("ADODB.Command")
      thecommand.CommandType = cnstCommand
      thecommand.CommandText = "LOG_CONNECTION_EVENT"
      thecommand.ActiveConnection = connectionString
      Set Fields.VarGlobal02 = thecommand

      End If

      Thanks,
      Curt

        • Re: Issue with checking condition of a global variable
          Kuz

          Hi Curt,

          Restarting the Kiwi Syslog Service will always clear (uninitialize) the Global (and Custom) variables.

          That said, please bear in mind that if you are running script tests though the Kiwi Syslog Manager, then it (Kiwi Syslog Manager) maintains it's own sandboxed versions of the VarGlobals.  You will need to restart the manager in order to clear those.

           

          If you want to explicitly uninitialize a Global Variable, add the following statement to the script:

          Fields.VarGlobal02 = Empty

           

          You may also want to use the isEmpty function to check for an initialized variable, instead of VarType.

          eg. 

          If IsEmpty(Fields.VarGlobal02)  Then

             'Initialize variable

             ...

           

          End If

          (http://www.w3schools.com/vbScript/vbscript_ref_keywords.asp)