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>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong> <strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong><br />

End Property<br />

End Class<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 />

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

A couple notes on the example above. The CreateObject command is used to instantiate an Object<br />

that is known at the system level (e.g. a COM object). Also, so far this example only shows how to<br />

assign and retrieve property values. It is generally the Method(s) that control the action an object<br />

per<strong>for</strong>ms, not the properties.<br />

A Property can be made read-only by only providing a Property Get procedure, or by declaring the<br />

Property Let procedure as Private instead of Public. A Property can be made write-only by only<br />

providing the Property Let procedure, or by declaring the Property Get procedure as Private instead of<br />

Public.<br />

Class Methods are really just Functions and Subroutines inside of a Class block. These functions and<br />

subroutines can be either Private or Public. If they are public, they will be accessible to a <strong>VBScript</strong> code<br />

segment outside of the Class block by referencing the obj.Method. If they are private, they will only be<br />

available to code within the Class block.<br />

An example of Class Methods 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 />

Public Sub Delete ‘Method to delete the master file<br />

master_FSO.DeleteFile (master_file)<br />

End Sub<br />

End Class<br />

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

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

Saved successfully!

Ooh no, something went wrong!