Skip to main content

Search

Search

Truncating

Comments

1 comment

  • Avatar
    Peter Thane

    There are a couple of ways you  could achieve this but probably the simplest would be to add a simple VB field that counts the number of characters in the main string and then use that to suppress the other 2 fields when they are not required.

    The main/base field should be given a name to make it more easier to reference and I have called mine "TheNumber" via the highlighted button

    The second field is the counter and I have also named this "LetterCount" and have set this as a VB Script > Event Controlled Script. Depending on where the data from the base field is coming from (ie a Data Entry or Database) then you will need to add the VB at a relevant point. For mine I have set it to run OnPostPrompt and the VB I have used is 

    (I also set Value = 8 for the OnAutoSelected to give the field a default value)

    Value = Len(Format.NamedSubStrings("TheNumber").Value)

     

    To add this type in the Value = and then from the Script Assistant box on the right expand the Named Data Sources and double click on TheNumber to add the rest of the code.

    The field for the first 8 digits is set as an ObjectValue field linked to the Main/Base text field and with Truncation set to Keep characters on left 8.

    The 3rd text field is similar to the above but is set to Discard 17 characters from the left plus has Suppression enabled so that it is suppressed unless LetterCount = 25 characters.

     

    The text for second string of 8 is made up of two ObjectValue substrings similar to the other two fields. The first of these has Truncation set to discard 9 charcaters on the left but is suppressed unless the LetterCount = 16

    Note to add a second substring use either the button highlighted or the copy and paste feature underlined on the below

     

    The second substring is suppressed if the previous string is not empty and this is set to Truncate, Discard characters on right = 9 and Discard on left = 9.

    I hope this helps

     

     

     

     

    0

Please sign in to leave a comment.