Skip to main content

Search

Search

Scanning A Character Location From A Prompt Input

Comments

3 comments

  • Avatar
    Legacy Poster

    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

    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

    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.

    0

Please sign in to leave a comment.