system.tag.readBlocking not working with client tags from inside a shared project library

system.tag.read(tag) from or the newer system.tag.radBlocking fails to return the client tags when called from a script in the the Project Library, but works just fine when you have it in a event handler.

This works fine in the event handler;
DataColorsPath=’[client]_System/Appearance/EntryForm’
print system.tag.read(DataColorsPath+’/DataValid’)
print system.tag.read(DataColorsPath+’/DataValid’).value
print system.gui.color(system.tag.read(DataColorsPath+’/DataValid’).value)

But if you put this in a project library;
shared.EAM.GUI.Entry.BkTxtMaxLen(event,DataColorsPath=’[client]_System/Appearance/EntryForm/DataValid’)

def BkTxtMaxLen(Event,DataColorsPath=’[Client]_System/Appearence/EntryForm’):

print DataColorsPath
print system.tag.readBlocking([DataColorsPath+’/DataValid’])[0]
print system.tag.read(DataColorsPath+’/DataValid’)

Sorry last post posted before the library code was pasted in;

def BkTxtMaxLen(Event,DataColorsPath=’[Client]_System/Appearence/EntryForm’):
print DataColorsPath
print system.tag.readBlocking([DataColorsPath+’/DataValid’])[0]
print system.tag.read(DataColorsPath+’/DataValid’)

Well just return;
[client]_System/Appearance/EntryForm/DataValid
[null, Bad_NotFound, Sat Oct 30 13:46:52 PDT 2021 (1635626812978)]
[null, Bad_NotFound, Sat Oct 30 13:46:52 PDT 2021 (1635626812979)]

You defined it in a project library but where are you calling it from?

1 Like

Kevin is hinting at the fact that project libraries, by themselves, have no scope. Their scope is determined by from where they are called. A gateway event can call a project script and it will be gateway scope. A Vision client event or component event can call the same script and it will be Vision client scope.

I’m calling it from the event it’s self. In 7.9 we have these library calls on all of are objects on the form. It basically changes the color of the background the text object should they enter text that is to long to be entered into the data base. But in 8.0 and 8.1 in doing so now you get a bad tag reference. In the above code, the tags print just find in the event, then in the same event I make a call to BkTxtMaxLen and have the same print statements, but they return tag not found. (Is there a import of some sort I have to do in version 8?)

What event is that?

On the property change event the one one line of code is;

shared.EAM.GUI.Entry.BkTxtMaxLen(event)

The full code in this library is;

def BkTxtMinMaxLen(Event,MinLen,DataColorsPath='[Client]_System/Appearence/EntryForm'):	
	"""Written:06/30/20  By:Gerry Huck   Last Rev:  /  /      By:                        Rev 1.0b
	Background color of a text widget when the under the min or larger then the max length, called from a propertyChange event.
	For Text widgets set props to MDeferUpdates=0, CommitOnFocusLoss=1, RejectUpdatesDuringEdit=1"""
	if Event.propertyName == 'text':
		if len(Event.source.text) > MinLen:
			Event.source.editableBackground = system.gui.color(system.tag.read(DataColorsPath+'/DataValid').value)
		else:
			Event.source.editableBackground = system.gui.color(system.tag.read(DataColorsPath+'/DataRequired').value)
	elif Event.propertyName == 'editValid':
		if len(Event.source.text) > Event.source.maxChars:
			Event.source.editableBackground = system.gui.color(system.tag.read(DataColorsPath+'/DataError').value)
		else:
			Event.source.editableBackground = system.gui.color(system.tag.read(DataColorsPath+'/DataValid').value)

Sorry grab the wrong library although it will do the same thing;

def BkTxtMaxLen(Event,DataColorsPath='[Client]_System/Appearence/EntryForm'):	
	"""Written:04/15/17  By:Gerry Huck   Last Rev:  :  :      By:                        Rev 1.0
	Background color of a text widget when the max length has been reached, called from a propertyChange event.
	For Text widgets set props to MDeferUpdates=0, CommitOnFocusLoss=1, RejectUpdatesDuringEdit=1"""
	if Event.propertyName == 'text':
		if len(Event.source.text) <= Event.source.maxChars:
			Event.source.editableBackground = system.gui.color(system.tag.read(DataColorsPath+'/DataValid').value)
	elif Event.propertyName == 'editValid':
		if Event.newValue:
			Event.source.editableBackground = system.gui.color(system.tag.read(DataColorsPath+'/DataValid').value)
		else:
			Event.source.editableBackground = system.gui.color(system.tag.read(DataColorsPath+'/DataError').value)

Huh. I’m stumped.

I was hoping there was a simple solution. Would it be better if I open a call with support. The reason I went this route is my 8.1 test box does not have a license on it. I’m I’m starting to test all of are licensed 7.9.+ systems on that test box before putting together a upgrade plan for next year.

I’m curious, try adding import system to the shared script.

Had no affect, tag still return as Bad_NotFound.

It was a shot in the dark. I had some weird things happening in perspective when using global scripts in the script console that needed to Import system to work.