Variables

 

Remarks Properties Methods Samples

ED
avaliable
RT
avaliable

Remarks:Top

The collection Variables contains all defined variables of the current project. With this collection you can access, create and delete variables.
Beside the access via the index a variable also can be found with its unique name or the unique channel Id.

Properties:Top

Count Parent  

Methods:Top

CheckInModule CheckOutModule CreateArrayVar
CreateVar DeleteVar DoAutoSave
Export Import ImportDirect
Item ItemPvID  

Samples:Top

Sub CreateVars()
Dim zPRJ As Project
Dim zDRV As Driver
Dim zVTp As VarType
Dim i
'part of the Variablename...
Const VarNamePart As String = "TEST_"

	Set zPRJ = MyWorkspace.ActiveDocument
	'set first created driver....
	Set zDRV = zPRJ.Drivers.Item(0)
	'check if driver is the "INTERNAL" driver
	If InStr(1, zDRV.Name, "Intern", vbTextCompare) = 0 Then Exit Sub
	'set vartype (UINT)
	Set zVTp = zPRJ.VarTypes.Item("UINT")
	For i = 0 To 9
		zPRJ.Variables.CreateVar VarNamePart & i, zDRV, tpSystemVariable, zVTp
	Next i
End Sub

Sub DeleteVars()
Dim zPRJ As Project
Dim i
'part of the Variablename...
Const VarNamePart As String = "TEST"

	Set zPRJ = MyWorkspace.ActiveDocument
	'run trough all variables of the active project
	For i = zPRJ.Variables.Count - 1 To 0 Step -1 'reverse loop!
		'search part of the varname
		If InStr(1, zPRJ.Variables.Item(i).Name, VarNamePart) <> 0 Then
			'delete variable
			If zPRJ.Variables.DeleteVar(zPRJ.Variables.Item(i).Name) = False Then
				Debug.Print "ERROR deleting: " & zPRJ.Variables.Item(i).Name
			End If
		End If
	Next i
End Sub