I created a project script the adds a row to a dataset and sets the columns text…this works fine, I tested it with a button in the Designer in Preview mode and from a Client window via a button script. The script name is addVersionNote (projectArea, topic, notes) and is provided at the bottom of this post.
I created project script isFlagTrue(flagName) (also shown at the bottom of the post) that returns a Boolean with for specific system flag. This works, I tested it in Designer in Preview mode and from a Client window via a button script.
I changed my button script to:
if sysUtil.isFlagTrue('Designer'):
versioning.addVersionNote('button script', 'Designer', 'if sysUtil.isFlagTrue(Designer):')
if sysUtil.isFlagTrue('Client'):
versioning.addVersionNote('button script', 'client', 'if sysUtil.isFlagTrue(Client):')
This also works fine, I tested it in Designer in Preview mode and from a Client window via a button script.
I copied the first ‘if’ (checking if the Designer is running) and pasted it in the Client Event Startup and Shutdown script area. When I start up and shut down the Designer my dataset doesn’t get a new row…its as if the first bit in the SystemFlags integer is zero.
Is there some special conditions on how the SystemFlag bits are set? Perhaps only after startup scripts are executed? What about when shutting down?
As usual, thanking you helpful people in advance.
Regards,
Ted.
def addVersionNote (projectArea, topic, notes):
# =================================================================================================================
# Adds a new version note row to the beginning of the version information dataset.
# =================================================================================================================
# Get the current dataset from the memory tag. Remember, .readBlocking returns a List.
currentDataSet = system.tag.readBlocking('[gw1]_Project Version Information/versionDataSet')[0].value
# Create the data for the new row and make the row.
date = system.date.now()
projectName = system.tag.readBlocking('[System]Client/System/ProjectName')[0].value
projectVersion = system.tag.readBlocking('[gw1]_Project Version Information/versionString')[0].value
userName = system.tag.readBlocking('[System]Client/User/Username')[0].value
newRow = [[date, projectName, projectVersion, userName, projectArea, topic, notes]]
# Add the row to the dataset getting the new dataset.
newDataSet = system.dataset.addRows(currentDataSet, 0, newRow)
# Write the new dataset to the memory tag (because we need to remember it :)
system.tag.writeBlocking('[gw1]_Project Version Information/versionDataSet', newDataSet)
def isFlagTrue(flagName):
# =================================================================================================================
# Find out if one to the system.util.getSystemFlags() flags is true..or not :)
# =================================================================================================================
"""
system.util.getSystemFlags() returns an integer that represents a bit field containing information about the
currently running system. Each bit corresponds to a specific flag as defined in the bitmask below. The integer
return will be a total of all of the bits that are currently active. Note that tag[System]Client/System/SystemFlags
contains the same value.
Flag Description / Bit Value
==== =======================
Designer Set if running in the Designer / 1
Preview Set if running in the Designer, and the Designer is in preview mode / 2
Client Set if running as a Client / 4
Webstart Set if running as a Client in Web Start mode / 8
Applet Set if running as a Client in Applet mode / 16
Fullscreen Set if running as a Client in full screen mode / 32
SSL Set if communication to the Gateway is encrypted with SSL / 64
Mobile Set if currently running a mobile-launched client / 128
"""
retVal = False
flagList = []
flags = system.util.getSystemFlags()
for i in range(7,-1,-1):
flagList.insert(0, flags >> i & 1)
if (flagName == 'Designer' and (flagList[0] == 1)):
retVal = True
elif (flagName == 'Preview'and (flagList[1] == 1)):
retVal = True
elif (flagName == 'Client' and (flagList[2] == 1)):
retVal = True
elif (flagName == 'Webstart' and (flagList[3] == 1)):
retVal = True
elif (flagName == 'Applet' and (flagList[4] == 1)):
retVal = True
elif (flagName == 'Fullscreen' and (flagList[5] == 1)):
retVal = True
elif (flagName == 'SSL' and (flagList[6] == 1)):
retVal = True
elif (flagName == 'Mobile' and (flagList[7] == 1)):
retVal = True
return retVal