Accessing General Property from a Web Behavoir Tool
I want to set the variable "STag" by pressing the Button "Show Tag", and reset the variable by pressing the button again.
Voted best answer
As I said setPropertyValue() isn't a build in function, you have to implement it:
Function setPropertyValue(ByVal reqPropName, ByVal reqAspectCategoryId, ByVal reqAspectName, ByVal propValue)
' Just get the interface to the property, and, if received, set the value
setPropertyValue = false
dim requestedPropertyInterface
set requestedPropertyInterface = getPropertyInterface(reqPropName, reqAspectCategoryId, reqAspectName)
if not requestedPropertyInterface Is Nothing then
On Error Resume Next
requestedPropertyInterface.value = propValue
setPropertyValue = true
end if
set requestedPropertyInterface = Nothing
End Function
This function use getPropertyInterface(), which you have to implement too (look at the complete code from my second answer, thats why I post it)
I think your code should like (you can not use VB syntax):
function OnButtonClick()
{
success = setPropertyValue( "STag", "{A3E921BC-D251-11D3-8209-080009DC441A}",
"ShowTag Property", true );
}
function setPropertyValue()
{
...
getPropertyInterface();
...
}
function getPropertyInterface()
{
...
}
/Erik
Answers
I'm not sure if it works in your case but for normal objects:
Sub setOn()
' Set the property VALUE on the aspect Control Connection
dim success
success = setPropertyValue( "VALUE", "GUID Object", "Control Connection", true )
End Sub 'setOn
Hello Erik,
Thank you for your quick reply.
I am not very familiar with scripting.....
About the "GUID Object":
In my Case it is the "General Properties, Aspect Category" in the Aspect System Structre?
And the "reqApsectName" is "ShowTag Property"?
So i have to write:
<ABB:Tool
type="button"
id="btnTag"
title="Show Tag"
Image="#resource#(Gif)">
</ABB:Tool>
<script defer>
Sub setOn()
' Set the property VALUE on the aspect ShowTag Property
dim success
success = setPropertyValue("VALUE","{A3E921BC-
D251-11D3-8209-080009DC441A}","ShowTag Property",true)
End Sub 'setOn
</script>
Am I right?
BR
Sebastian
That looks ok to me. But you need some more code and a button or something else to call the function (or verb).
You may search for "scripting verbs" in 800xA. I know them from the Advant Connectivity:
See the Code below for the implemantation of "setPropertyValue" and other functions:
Option Explicit
' Add your code here.
' *******************************************************************************
****************************
Sub Man()
' Set the property MAN_MODE on the aspect Control Connection
dim success
success = setPropertyValue( _
"MAN_MODE", _
"{A3E921BA-D251-11D3-8209-080009DC441A}", _
"Control Connection", _
true )
End Sub 'Man
' *******************************************************************************
****************************
Sub Auto()
' Reset the property MAN_MODE on the aspect Control Connection
dim success
success = setPropertyValue( _
"MAN_MODE", _
"{A3E921BA-D251-11D3-8209-080009DC441A}", _
"Control Connection", _
false)
End Sub 'Auto
' *******************************************************************************
****************************
Sub setOn()
' Set the property VALUE on the aspect Control Connection
dim success
dim man_mode
success = getPropertyValue( _
"MAN_MODE", _
"{A3E921BA-D251-11D3-8209-080009DC441A}", _
"Control Connection", _
man_mode)
if success and man_mode then
success = setPropertyValue( _
"VALUE", _
"{A3E921BA-D251-11D3-8209-080009DC441A}", _
"Control Connection", _
true )
end if
End Sub 'setOn
' *******************************************************************************
****************************
Sub setOff()
' Reset the property VALUE on the aspect Control Connection
dim success
dim man_mode
success = getPropertyValue( _
"MAN_MODE", _
"{A3E921BA-D251-11D3-8209-080009DC441A}", _
"Control Connection", _
man_mode)
if success and man_mode then
success = setPropertyValue( _
"VALUE", _
"{A3E921BA-D251-11D3-8209-080009DC441A}", _
"Control Connection", _
false)
end if
End Sub 'setOff
' *******************************************************************************
****************************
' ===============================================================================
============================
' The code below the line is provided by the template in a copy fashion. Replace this if there is reason to
' change the template code. There are examples of usage in the beginning.
' *******************************************************************************
****************************
' Example that shows how to set the value of a boolean property named "motorEnabled'. This example is
' applicable if a property is accessed only once. See the description of "setPropertyValue" for an explanation
' of the parameters.
' -------------------------------------------------------------------------------
------------------------------
'Sub stopMotor()
' ' Reset the property 'motorEnabled' on the aspect 'General Motor Properties'
' dim success
' success = setPropertyValue( _
' "motorEnabled", _
' "{BA81F5B3-497E-11D3-8591-0060B0CEAB60}", _
' "General Motor Properties", _
' false)
'End Sub
' *******************************************************************************
****************************
' *******************************************************************************
****************************
' Example that shows how to use a property interface. This example is applicable if a property is accessed
' more than once. See the description of "getPropertyInterface" for an explanation of the parameters.
' -------------------------------------------------------------------------------
------------------------------
'Sub accessSeveralTimes()
' dim propertyInterface
' set propertyInterface = getPropertyInterface("testBool", "{BA81F5B3-497E-11D3-8591-0060B0CEAB60}", _
' "General Properties")
' if not propertyInterface is nothing then
' ' Found an interface so start working
' if propertyInterface.value = false then
' propertyInterface.value = true
' else
' propertyInterface.value = false
' end if
' end if
' set propertyInterface = Nothing
'End Sub
' *******************************************************************************
****************************
' *******************************************************************************
****************************
' Function setPropertyValue Returns a boolean set to true if success, otherwise false
' Parameters:
' reqPropName The name (string) of the requested property
' reqAspectCategoryId The GUID (string) for the requested aspect category, including the "{" and "}"
' reqAspectName The name (string) of the requested aspect
' propValue The new property value
'
' Note that this routine browses for the property interface. If a property is accessed more than once, a much
' more efficient method is to capture the interface using routine getPropertyInterface, and then act directly
' on the "value" property using that interface.
' Assuming an aspect supports the requested property, aspect category identity and aspect name match override
' pure aspect category match.
' -------------------------------------------------------------------------------
------------------------------
Function setPropertyValue(ByVal reqPropName, ByVal reqAspectCategoryId, ByVal reqAspectName, ByVal propValue)
' Just get the interface to the property, and, if received, set the value
setPropertyValue = false
dim requestedPropertyInterface
set requestedPropertyInterface = getPropertyInterface(reqPropName, reqAspectCategoryId, reqAspectName)
if not requestedPropertyInterface Is Nothing then
On Error Resume Next
requestedPropertyInterface.value = propValue
setPropertyValue = true
end if
set requestedPropertyInterface = Nothing
End Function
' *******************************************************************************
****************************
' *******************************************************************************
****************************
' Function getPropertyValue Returns a boolean set to true if success, otherwise false
' Parameters:
' reqPropName The name (string) of the requested property
' reqAspectCategoryId The GUID (string) for the requested aspect category, including the "{" and "}"
' reqAspectName The name (string) of the requested aspect
' propValue The property value
'
' Note that this routine browses for the property interface. If a property is accessed more than once, a much
' more efficient method is to capture the interface using routine getPropertyInterface, and then act directly
' on the "value" property using that interface.
' Assuming an aspect supports the requested property, aspect category identity and aspect name match override
' pure aspect category match.
' -------------------------------------------------------------------------------
------------------------------
Function getPropertyValue(ByVal reqPropName, ByVal reqAspectCategoryId, ByVal reqAspectName, ByRef propValue)
' Just get the interface to the property, and, if received, get the value
getPropertyValue = false
dim requestedPropertyInterface
set requestedPropertyInterface = getPropertyInterface(reqPropName, reqAspectCategoryId, reqAspectName)
if not requestedPropertyInterface Is Nothing then
propValue = requestedPropertyInterface.value
getPropertyValue = true
end if
set requestedPropertyInterface = Nothing
End Function
' *******************************************************************************
****************************
' *******************************************************************************
****************************
' Function getPropertyInterface Returns the requested interface, or "Nothing" upon failure
' Parameters:
' reqPropName The name (string) of the requested property
' reqAspectCategoryId The GUID (string) for the requested aspect category, including the "{" and "}"
' reqAspectName The name (string) of the requested aspect
'
' Assuming an aspect supports the requested property, aspect category identity and aspect name match override
' pure aspect category match.
' -------------------------------------------------------------------------------
------------------------------
Function getPropertyInterface(ByVal reqPropName, ByVal reqAspectCategoryId, ByVal reqAspectName)
' Loop through all aspects and try to find best candidate. Break looping if name and category matches.
set getPropertyInterface = Nothing
dim auxProperty ' Used as auxiliary property
dim auxAspect ' Used as auxiliary aspect
dim categoryAndNameHit
categoryAndNameHit = false
dim categoryHit
categoryHit = false
for each auxAspect in object.aspects
if auxAspect.AspectCategory.object.Id = reqAspectCategoryId then
' Found an aspect of correct aspect category
for each auxProperty in auxAspect.properties
if auxProperty.shortName = reqPropName then
' Found matching category containing the requested property
if auxAspect.name = reqAspectName then
' Found a category of correct type, with the requested name,
' and containing requesed property
set getPropertyInterface = auxProperty
categoryAndNameHit = true
exit for
else
if not categoryHit then
' No earlier pure category hit found,
' so store this first one
set getPropertyInterface = auxProperty
categoryHit = true
exit for
end if
end if
end if
next
if categoryAndNameHit = true then
' A better match can not be achieved, so break the searching
exit for
end if
end if
next
set auxProperty = Nothing
set auxAspect = Nothing
End Function
' *******************************************************************************
****************************
The Web Behavoir Tool Aspect "Show Tag" is allready my button which is connected to Application bar at my Workplace.
The script was written inside that Aspect.
I don't think I need to use the "scripting verbs" in my case.
I can not deal with these information.
Maybe we are talking about two different things, I try to explain it in more detail:
I implemented a Tool-Button "Show Tag" on my workplace, with this button I want to set the Property "STag" in the General Property Aspect "ShowTag Property".
I tryd to implement Subset On():
***********************************************
<ABB:Tool
type="button"
id="btnTag"
title="Show Tag"
Image="#resource#(Gif)">
</ABB:Tool>
<script defer>
function OnButtonClick()
{
Sub setOn()
' Set the property VALUE on the aspect ShowTag Property
dim success
success = setPropertyValue( "STag", "{A3E921BC-D251-11D3-8209-080009DC441A}",
"ShowTag Property", true )
End Sub 'setOn
}
Add new comment