How to correctly assign to a named data source (BT 10.1 SR4)
I have been using Format.NamedSubStrings("mydatasource").Value for a long time to both get and set values of named data sources. However, I've recently noticed that assigning this way doesn't actually seem to be intended?
Say I have a data source called mydatasource somehwere on the label and then have VBScript in the OnAutoSelectedEvent with this simple code:
Format.NamedSubStrings("mydatasource").Value = "test"
...while the value "test" does actually get assigned to mydatasource, the script triggers a "Script Endless Loop" error immediately aftewards. Say I have 2 such lines of code, the second one doesn't even get executed anymore.
That said, when printing, it does seem to work fine. But I couldn't actually find any reference in the help documentation explicitely mentioning that the above is allowed - so now I wonder whether I've been "doing it wrong" all this time?
-
The method Format.NamedSubStrings("mydatasource").Value is intended to be used to set and get values of named data sources on the label design. Do note that OnAutoSelectedEvent is called whenever the value of the data source is needed.
I was successfully able to replicate the issue in v10.1 SR4 by doing the following:
1. Created two named data sources named "mydatasource" and "mydatasource2"
2. Create a new text object with a data source using vbscript on event control scripts and OnAutoSelectedEvent using the vbscript code:
Format.NamedSubStrings("mydatasource").Value = "test"
Format.NamedSubStrings("mydatasource2").Value = "test2"I can see the value return "script endless loop" message. Like you mentioned, everything still appears to work correctly.
However, I tried the same thing in our latest version 2016 R4, and the issue doesn't replicate so it seems something that was fixed in 2016.
1 -
KM3
★ BarTender Hero ★
Hi Jasper
Many thanks for your helpful response. It's good to hear that this method is intended to be used the way I did - otherwise I would have had to change this in a lot labels... :-)
One more thing I forgot to mention: The error message does not appear if I assign to the data source like this:
MYDATASOURCE = "test"
However, that only works if the data source name is capitalized and does not contain any special characters (hence why I prefer Format.NamedSubStrings).
0
Please sign in to leave a comment.
Comments
2 comments