Skip to main content

Search

Search

Update Nameddatasource Through Onidenticalcopies?

Comments

7 comments

  • Avatar
    Ian Cummings
    Moderator

    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

    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

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

    0
  • Avatar
    Ian Cummings
    Moderator

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

    0
  • Avatar
    Legacy Poster

    Ok, thanks :)

     

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

    0
  • Avatar
    Ian Cummings
    Moderator

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

    0
  • Avatar
    Legacy Poster

    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...

    0

Please sign in to leave a comment.