State

 

Description

 

Sets or returns the mode of the ScriptControl object. Read/write.

 

PowerBASIC Syntax

 

PROPERTY GET State () AS LONG

PROPERTY SET State (BYVAL pssState AS LONG)

 

Arguments

 

pssState

The state argument can be either of the following constants:

 

Constant

Value

Desription

Initialized

0

The scripting engine will execute the code but will not sink any events generated by objects added using the AddObject method.

Connected

1

The scripting engine will sink events generated by objects added using the AddObject method.

 

Example [PowerBASIC]

 

#INCLUDE "MSSCRIPT.INC"

 

DIM pSc AS IScriptControl

DIM strScript AS STRING

DIM nState AS LONG

 

' Create an instance of the Microsoft Script Control

pSc = NEWCOM "MSScriptControl.ScriptControl"

' Set the language. It can be "VBScript" or "JScript"

pSc.Language = UCODE$("VBScript")

' Deactivate the user interface

pSc.AllowUI = %VARIANT_TRUE

' Make an script

strScript = "Sub Main" & $CRLF & _

            "   MsgBox ""Hello everybody.""" & $CRLF & _

            "End Sub"

pSc.AddCode UCODE$(StrScript)

' Reterieve the state of the ScriptControl object

nState = pSc.State

IF nState = 0 THEN

  MSGBOX "State: Initialized"

ELSEIF nState = 1 THEN

  MSGBOX "State: Connected"

END IF

 

Valid XHTML 1.0 Transitional