Scanning A Character Location From A Prompt Input Follow

0
Avatar
Legacy Poster

Using Bartender 9.3

 

I am trying to print a label using my prompt design.

 

For one of my prompt inputs, I want to check a letter that will always be at the same location.  Based on what that character is, I determine what a different field should be.

 

Example:

If I scan "WidgetA1234", I will see the 'A' in the middle and know that the description is "Simple Widget"

If I scan "WidgetB2345", I will see the 'B' in the middle and know that the description is "Super Widget"

In both cases, I want the scan "Widget...." and the description to appear on my label.

 

My VB attempt:

    OnProcessData
    IP = Split(PART,",")(6)
    If IP = "A" Then IP_Out = "Simple Widge"
 
Gives me: <Line 6: :Out of stack space: 'OnProcessData'>
 
 
Any hints on what I am doing wrong?  Is there a better way to do this?

3 comments

0
Avatar
Legacy Poster
Comment actions Permalink

All my VB is self taught so there maybe a simple way to do this but assuming the A or B etc. is always the 7th character then you could you:

 

1. For your Prompt entry field give this a Share Name. I used testwidget for the code below.

2. For your Super/Simple line set the string to an Event Controlled Post-Prompt script and then Edit it to the following, although for the first line you should select the Named sub-string list from the option at the bottom left of the VB screen (type the Value = and then click on the substring to add it).

 

Value = Format.NamedSubStrings("testwidget").Value
 
Value=Left(Value,7)
Value=Right(Value,1)
 
If Value = "A" then 
Value = "Simple Widget"
elseif Value = "B" then
Value = "Super Widget"
end if
 
Value = Value
 
You may want to amend the Autoselected Event value (default value before a prompt is entered) to Value = "xxxxx " where xxxx is the default value and you could also add line
Else Value = "No Widget" or similar before the end if line which would be displayed is an A or B was not found at character 7 is in the string.
 
I hope this helps
0
Avatar
Legacy Poster
Comment actions Permalink

Thanks! That definitely got me started in the right direction.

 

Two questions:

1. Merging your example with mine, should the last line be:

Format.NamedSubStrings("IP_Out").Value = Value

 

2. Your example is using the script located here:

File -> Bartender Document Options -> Visual Basic Script

 

I was doing mine within the object itself (Text 1 = testwidget):

Text 1 -> Transforms -> VB Script

 

Any advantages or disadvantages of placing the VB script in one place or the other?

0
Avatar
Legacy Poster
Comment actions Permalink

1. No just leave as Value = Value. That command would set the final value as whatever value is set in the IP_Out and so ignore the calculations above. If you had called the Prompt entry field IP_Out then the first line should be

   Value = Format.NamedSubStrings("IP_Out").Value

2. No my example sets the whole Data Source as a VB field rather than Text field with VB Transforms. To be honest I have not had a play with the File -> Bartender Document Options -> Visual Basic Script route and so I just use the method I know that allows me access the Event Controlled Scripts.

Please sign in to leave a comment.