18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong> <strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong><br />

Rem Below is the <strong>VBScript</strong> code<br />

Dim objFSO ‘ Declare variables and objects<br />

Dim objFilePointer, cur_file<br />

Set objFSO = CreateObject(“Scripting.FileSystemObject”) ‘ Instantiate the COM object<br />

Set objFilePointer = New FileSpec ‘ Instantiate the Class Object<br />

objFilePointer.FileName = “Myfile.mdb” ‘ Assigns “Myfile.mdb” as the file name<br />

cur_file = objFilePointer.FileName ‘ Retrieves the current file name “Myfile.MDB”<br />

Set objFilePointer.FSO = objFSO ‘ Assigns an Object to the Property<br />

objFilePointer.Delete ‘ Executes a Method to delete a file<br />

Set objFilePointer = Nothing ‘ Keyword Nothing releases the object memory<br />

<strong>VBScript</strong> Class Objects automatically supports two type of Class Events; Class_Initialize and<br />

Class_Terminate Events. The code inside the Class_Initialize event executes once when an Object<br />

based on the Class is first instantiated. Any code put in this event is optional, and is typically used <strong>for</strong><br />

initialization. Code inside the Class_Terminate event executes once just be<strong>for</strong>e the Object based on the<br />

Class is destroyed (i.e. Set to Nothing, or the Object goes out of scope). Usage is as follows:<br />

Class FileSpec<br />

Private master_file<br />

Private master_FSO Private master_file<br />

Private Sub Class_Initialize ‘ Class Object initialization code<br />

‘ code goes here<br />

End Sub<br />

Private Sub Class_Terminate ‘ Class Object termination code<br />

‘ code goes here<br />

End Sub<br />

Public Property Let FileName(strName) ‘ Define a Public Property to assign the file name<br />

master_file = strName<br />

End Property<br />

Public Property Get FileName ‘ Define a Public Property to retrieve a file name<br />

FileName = master_file<br />

End Property<br />

Public Property Set FSO(m_FSO) ‘ Define a Public Property <strong>for</strong> an object<br />

Set master_FSO = m_FSO<br />

End Property<br />

End Class<br />

<strong>InduSoft</strong>, Ltd. 27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!