Ajuste de propriedade via script

Bom dia!

Existe alguma forma de, via script em modo de configuração, alterar uma propriedade de todos os objetos de uma determinada classe dentro do projeto?

Obrigado pela ajuda!

Sub Foobar_CustomConfig()
	Dim dict
	Dim sClassName
	Dim sPropertyName
	Dim vNewValue
	
	ListFilesEx dict
	
	' Edit here
	' sClassName = "IOTag"
	' sPropertyName = "DocString"
	' vNewValue = "Documentation string"
	
	sClassName = "InternalTag"
	sPropertyName = "Value"
	vNewValue = 42

	SetNewValues dict, sClassName, sPropertyName, vNewValue
End Sub

Private Sub SetNewValues( MyApp, ClassName, PropertyName, NewValue )
	Dim obj
	For Each obj In MyApp
		If ( LCase(TypeName( obj )) = LCase(ClassName) ) Then
			Execute("obj." & PropertyName & " = NewValue")
		Else
			SetNewValues obj, ClassName, PropertyName, NewValue
		End If
	Next
	
End Sub

Private Sub ListFilesEx( ByRef d )
	Dim oColl
	Dim elem
	Set d = CreateObject("Scripting.Dictionary")
	
	For Each elem In Array( _
			"DataServer", _
			"IODriver", _
			"DBServer", _
			"AlarmServer" _
		)
		
		Set oColl = Application.ListFiles( elem )
		
		d.Add oColl, Nothing
	Next
End Sub
2 Likes