Vbscript Error "object Required" Follow

0
Avatar
Legacy Poster

I am trying to learn a little VB script. I have an object with 4 sub-strings. First sub-string is called CompBox, second is preset data, third is another text box called QtyBox, fourth is a drop down called UnitBox with 3 values--%,PPM, and BALANCE. If drop down box is set to BALANCE, then I want to suppress text box 3. Here is what I have, and follows is the error I'm getting.

If UnitBox = BALANCE Then
QtyBox.visible = False
Else
QtyBox.visible = True
End If

Error is

Bartender:Error Message #6900

The following script error was found:

<Line 6:: Object required: 'QtyBox'>

Please help, what am I doing wrong? Remember, I'm a total newb.

17 comments

0
Avatar
Ian Cummings
Moderator

Which version of BarTender are you using?

Assuming a recent version:

Is "Text Box 3" a separate label object that you wish to not print depending on the value of a sub-string in a different object?

If yes to the above then you need to run a format level VB script found via the "File>BarTender Document Options" menu item. Choose the appropriate event and enter in something like the below VB script.

[code]
If Format.NamedSubStrings("UnitBox").Value = "BALANCE" Then
Format.Objects("Text Box 3").PrintVisibility = False
Else
Format.Objects("Text Box 3").PrintVisibility = True
End If
[/code]
0
Avatar
Michael Toupin (mtoupin

[quote name='drewh' timestamp='1358038774' post='4042']
I am trying to learn a little VB script. I have an object with 4 sub-strings. First sub-string is called CompBox, second is preset data, third is another text box called QtyBox, fourth is a drop down called UnitBox with 3 values--%,PPM, and BALANCE. If drop down box is set to BALANCE, then I want to suppress text box 3. Here is what I have, and follows is the error I'm getting.

If UnitBox = BALANCE Then
QtyBox.visible = False
Else
QtyBox.visible = True
End If

Error is

Bartender:Error Message #6900

The following script error was found:

<Line 6:: Object required: 'QtyBox'>

Please help, what am I doing wrong? Remember, I'm a total newb.
[/quote]


The error that you're getting is because the term 'QtyBox' isn't named as an object. When you're doing object references, you have to actually use the name of the object, not a substring name. So it should look more like this:

Format.Objects("Text Field 3").PrintVisibility = true
0
Avatar
Legacy Poster

[quote name='Mike T - Seagull Support' timestamp='1358183220' post='4055']
The error that you're getting is because the term 'QtyBox' isn't named as an object. When you're doing object references, you have to actually use the name of the object, not a substring name. So it should look more like this:

Format.Objects("Text Field 3").PrintVisibility = true
[/quote]
This is were further confusion is coming into play on my part, because I thought sub-strings were also objects. When I select a sub-string object in my primary object, I go to more options, and in Prompting I can select properties, and on the general tab there, it appeared that that is where the sub-string object gets named. Obviously, that's not the case. Can you see the confusion? Take a look at the attachment, and check the properties of the object shown as empty. There are 4 sub-strings (I think). Honestly, I am more confused now than ever. Maybe you could see where my naming is going wrong.
0
Avatar
Legacy Poster

[quote name='Ian C - Seagull Support' timestamp='1358181024' post='4051']
Which version of BarTender are you using?

Assuming a recent version:

Is "Text Box 3" a separate label object that you wish to not print depending on the value of a sub-string in a different object?

If yes to the above then you need to run a format level VB script found via the "File>BarTender Document Options" menu item. Choose the appropriate event and enter in something like the below VB script.

[code]
If Format.NamedSubStrings("UnitBox").Value = "BALANCE" Then
Format.Objects("Text Box 3").PrintVisibility = False
Else
Format.Objects("Text Box 3").PrintVisibility = True
End If
[/code]
[/quote]
Hi, I think I've got a more fundamental issue with object references that hopefully Mike T is looking into, but what you posted may certainly have relevance once I iron out the other problem. In answer to your question though, I'm trying to work with 1 object that has 4 sub-strings. I thought sub-strings were also referenced as objects as they appear to be labeled as objects in certain dialogues, but obviously that's incorrect.
0
Avatar
Ian Cummings
Moderator

Named sub-strings (which we now call data sources in v10) can indeed be termed as "objects" in a general programming sense. However, in BarTender there is such a thing called label objects (now called document objects in v10), which refer to the individual text, barcode, picture and drawing objects that make up the label design. When you wish to programmatically set the print visibility property of a label object, it is to this sort of object that you need to reference. Each label object is automatically given a name which can be changed if you wish to something more relevant.

Sub-strings (data sources) by contrast make up the data value of a given label object/s, but it is optional whether you give them a share name to make them reference'able in code.

In your example label I note that you've named the label objects, but you have not named individual sub-string data sources that allow you to reference their value. You need to specify a share name for a sub-string data source before you can then reference it in code.

Note the syntax for referencing these two different types of object:

Label Object:
Format.Objects("LabelObjectName")

Sub-String object:
Format.NamedSubStrings("SubStringName")
0
Avatar
Legacy Poster

[quote name='Ian C - Seagull Support' timestamp='1358244430' post='4061']
Named sub-strings (which we now call data sources in v10) can indeed be termed as "objects" in a general programming sense. However, in BarTender there is such a thing called label objects (now called document objects in v10), which refer to the individual text, barcode, picture and drawing objects that make up the label design. When you wish to programmatically set the print visibility property of a label object, it is to this sort of object that you need to reference. Each label object is automatically given a name which can be changed if you wish to something more relevant.

Sub-strings (data sources) by contrast make up the data value of a given label object/s, but it is optional whether you give them a share name to make them reference'able in code.

In your example label I note that you've named the label objects, but you have not named individual sub-string data sources that allow you to reference their value. You need to specify a share name for a sub-string data source before you can then reference it in code.

Note the syntax for referencing these two different types of object:

Label Object:
Format.Objects("LabelObjectName")

Sub-String object:
Format.NamedSubStrings("SubStringName")
[/quote]
Thanks Ian, I will take that into consideration. It does make sense, but hopefully you see my confusion. When I select more options on a specific sub-string, and go into the General settings, and again choose the General tab, the first field I see is Object name field, so I believe that's where the start of my confusion was. If I can get a working script, I think it should really help me with future tweaks. I don't think what I'm looking for is all that complicated, but it doesn't matter how small the creek is, if there's not bridge, you won't get across. Thanks again, I will let you know how it works.
0
Avatar
Legacy Poster

[quote name='drewh' timestamp='1358247833' post='4063']
Thanks Ian, I will take that into consideration. It does make sense, but hopefully you see my confusion. When I select more options on a specific sub-string, and go into the General settings, and again choose the General tab, the first field I see is Object name field, so I believe that's where the start of my confusion was. If I can get a working script, I think it should really help me with future tweaks. I don't think what I'm looking for is all that complicated, but it doesn't matter how small the creek is, if there's not bridge, you won't get across. Thanks again, I will let you know how it works.
[/quote]
Ian,

I believe I am able to properly reference the sub-strings now by creating share names. However, I am getting a different error that says the object does not support the property or method. I'm actually not sure where I need to put the script, and perhaps that's the problem. My guess is I need to actually build it in the label object and not in any of the sub-strings. Can you help me determine where a working script needs to go in this template? Both the latest template and script are attached for you to review.

The bottom line is that when I'm adjusting properties, it's not 100% clear to me what object is getting adjusted.

[attachment=372:IGD_Standard_Label_2.btw]
[attachment=373:VBScript.txt]
0
Avatar
Ian Cummings
Moderator

It looks like you are just wanting to set the "QtyBox" sub-string value to be nothing if the "UnitBox" sub-string value has a value of "BALANCE". Therefore, we are just affecting sub-string values here and not specfying label objects to print or not.

Use an OnProcessData VB script in the third sub-string (QtyBox) using the below expression:

[code]
If Format.NamedSubStrings("UnitBox").Value = "BALANCE" Then
value = ""
End If
[/code]

Ignore any error message which refers to the script not reading from the value property.
0
Avatar
Legacy Poster

[quote name='Ian C - Seagull Support' timestamp='1358265832' post='4069']
It looks like you are just wanting to set the "QtyBox" sub-string value to be nothing if the "UnitBox" sub-string value has a value of "BALANCE". Therefore, we are just affecting sub-string values here and not specfying label objects to print or not.

Use an OnProcessData VB script in the third sub-string (QtyBox) using the below expression:

[code]
If Format.NamedSubStrings("UnitBox").Value = "BALANCE" Then
value = ""
End If
[/code]

Ignore any error message which refers to the script not reading from the value property.
[/quote]
Ian,

Actually, I want QtyBox to be suppressed or invisible based on the value of BALANCE in Unitbox. Also, into what sub-string property does that script need to be installed? And why isn't there a reference to QtyBox since that's the sub-string that needs to be affected?
0
Avatar
Ian Cummings
Moderator

I guess you need to read my last post again.

By way of further explanation, because the VB script is in the OnProcessData of the QtyBox sub-string the "value = X" expression implicitly sets the value of that sub-string.
0
Avatar
Legacy Poster

[quote name='Ian C - Seagull Support' timestamp='1358269130' post='4074']
I guess you need to read my last post again.

By way of further explanation, because the VB script is in the OnProcessData of the QtyBox sub-string the "value = X" expression implicitly sets the value of that sub-string.
[/quote]
Okay, sorry for missing that. I did put that script in the correct place, but still not getting the desired result. Also, I will emphasize that I want QtyBox to actually be invisible when UnitBox is set to BALANCE. This way, I'm hoping in the Web Print Server that the user will not even be presented with the QtyBox if UnitBox is BALANCE. Does this make sense?
0
Avatar
Legacy Poster

Ian,

I got it working with the script you sent--kind of. I changed the script around to see if I could actually suppress the QtyBox in WPS based on the default reply of BALANCE. No luck there, the QtyBox still shows up. It won't print on the label, which is good, but I would like to prevent the user from even seeing that field if BALANCE is the UnitBox value. My guess is WPS has some limitations in this regard? Or maybe the script is just not forcing what I want.

Anyway, thanks for the help so far.
0
Avatar
Ian Cummings
Moderator

When you mention "WPS", are you referring to the BarTender Web Print Server?

I don't understand what you mean by, "the QtyBox still shows up". To my understanding QtyBox is just the name of your sub-string which we set to nothing if the other sub-string has a value of "BALANCE". In what way is it showing up?

Am I missing something?
0
Avatar
Legacy Poster

[quote name='Ian C - Seagull Support' timestamp='1358346538' post='4086']
When you mention "WPS", are you referring to the BarTender Web Print Server?

I don't understand what you mean by, "the QtyBox still shows up". To my understanding QtyBox is just the name of your sub-string which we set to nothing if the other sub-string has a value of "BALANCE". In what way is it showing up?

Am I missing something?
[/quote]
Yes I am referring to the Bartender WPS. I apologize if my choice of words is not technically spot on, but what I mean about "not showing up" is when a user gets presented with his label selection on the site page, I was thinking that the condition that I set up with VBscript would impact what displays on the WPS. In other words if the corresponding field for UnitBox sub-string on WPS is set to BALANCE, then the corresponding field for QtyBox would disappear. Conversely, if the user chose a value other than BALANCE, the corresponding field for QtyBox would appear.

In other words, I'm hoping for the user to do as little thinking as possible. If the field does not need populating, it should be invisible--out of sight, out of mind. It would also work to simply make the dynamic field inactive under certain conditions, if making it invisible is not practical/possible.

Does that make sense?
0
Avatar
Ian Cummings
Moderator

Unfortunately the preview in BT-WPS won't run any embedded VB script. This is a known limitation due to lack of feature, and how the web app was implemented. It should be the case however, that the printed result is correct. Going forward, we do intend to improve BT-WPS greatly over what it is now.
0
Avatar
Legacy Poster

[quote name='Ian C - Seagull Support' timestamp='1358524207' post='4120']
Unfortunately the preview in BT-WPS won't run any embedded VB script. This is a known limitation due to lack of feature, and how the web app was implemented. It should be the case however, that the printed result is correct. Going forward, we do intend to improve BT-WPS greatly over what it is now.
[/quote]
Okay, fair enough. Are there other web based solutions that Bartender can work with, like Apache that will support more complex scripting? I'm pretty new at this as you can tell. Didn't know how something like Java Script might function here.
0
Avatar
Ian Cummings
Moderator

BT-WPS is a pre-made web application that runs on an IIS web server. The embedded scripting that I was referring to is the script inside the BarTender label format that runs inside a BarTender process; not something like JavaScript that runs on a web page on the client side or a PHP script running on the server.

The label preview in in BT-WPS simply sets data for the various data sourced objects, and then exports it as an image to display in the client browser window. It is not a true print preview which might be altered with various validation rules and scripts inside the label format that only fire off during a real print job.

A custom made web application using the Web Printing SDK can be made to give the user experience that you want, with a proper print job preview, but that sort of project is something that only an experienced programmer should attempt.

Please sign in to leave a comment.