Update Nameddatasource Through Onidenticalcopies? Follow

0
Avatar
Legacy Poster

Hi,

 

Ok, I'm stumped - but I'm counting on you guys to know the answer :)

 

I have a script in OnIdenticalCopies in a text object. It is supposed to update a NamedDataSource in a different text object, every copy. But it doesn't. It only seems to "update" said NamedDataSource for the first copy.

 

I have broken the script down to the following:

count = count + 1
Format.NamedSubStrings("dummy").Value = count

What does work, is updating the text object itself (in which the script is located), like this:

count = count + 1
Value = count

My guess is that I assume this should work, while really, it shouldn't. My intent is to update several NamedDataSources (each copy) through the same script. How could I achieve this?

7 comments

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

If you set the values you want to variables in a document level script (functions and subs) and then from the objects set the values of the named data source to those variables you set in the document level scrip, I hope you'll get closer to where you want to be.

0
Avatar
Legacy Poster
Comment actions Permalink

Hi Ian,

 

Many thanks for your reply - and sorry for my late answer.

 

I have tried what you suggested but I couldn't get it to work. As I understand, I should declare (and assign values to) variables in "Functions and Subs" on Document Level and then reference these variables in a BarTender object. But when testing this through the "Preview" functionality, the data sources stay empty.

 

I have attached a file of what I understood and tried based on your post and then also a file clarifying what I want to do*. I also tried variations of your suggestion but I couldn't seem to get the variables' values "out of the Document Level" into my BarTender objects. The only way to achieve this was to assign values to a named data source (instead of a variable) but then I lost any update functionality since this doesn't work in the OnIdenticalCopies event.

 

*The reason I want only one script to assign values to several objects is that the values are ultimately supposed to come from a recordset populated by an ADO/OLEDB connection. I want to avoid having essentially the same script running in a dozen different objects and them all making the same connection (I'm a total VBS/programming noob but that just wouldn't feel right...)

0
Avatar
Legacy Poster
Comment actions Permalink

Any ideas...? I still don't fully understand why this doesn't work... :(

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

I think you'll just have to run the script in each object setting the value of that object directly.

0
Avatar
Legacy Poster
Comment actions Permalink

Ok, thanks :)

 

But... did my "idea" make sense? Could it be a feature request?

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

Sure, in general we're working on making scripting in BarTender more powerful.

0
Avatar
Legacy Poster
Comment actions Permalink

Follow-up:

I actually managed to circumvent this issue by taking a different approach. I'm now able to use a single script to do the file connection and return a record for every copy - but instead of trying to update the various other data sources, I just return the entire record using GetString(,1) in the data source itself, where the script is located. Then I use a very small script in each BarTender object to get the data from the aforementioned object/data source. I use Split() to get the desired element.

 

So basically, I switched from using a "push system" to a "pull system" and it works just fine. The only issue is that for some reason, the scripts in the various objects / data sources run before the "main" script that does the file connection and retrieves the records. As a result, when starting a print job, the data source is empty at the time the other scripts try to access it and I get an error (or an empty first label). I couldn't find a way to solve this other than by circumventing the issue again by adding a copy of the GetString(,1) part to OnAutoSelectedEvent which apparently effectively retrieves the first record before the other scripts try to access it - the main script and the small scripts are still 1 record out of sync but the labels print just fine...

Please sign in to leave a comment.