Skip to main content

Search

Search

.net Sdk - Test For Substrings

Comments

1 comment

  • Avatar
    Shotaro Ito
    [quote name='Richard S' timestamp='1342447149' post='2851']
    Is there a way of checking if a named substring exists on a format file before trying to set the value of the substring?
    [/quote]

    Hi Richard,
    You can list up all substrings in a document as sample below. (search .net SDK documentation by "Substrings".)

    [code]Public Sub Demo()
    ' Initialize a new BarTender print engine.'
    Using btEngine As New Engine()
    ' Start the BarTender print engine.'
    btEngine.Start()

    ' Open a format document.'
    Dim btFormat As LabelFormatDocument = btEngine.Documents.Open("C:\Format1.btw")

    ' Display the number of substrings in the format.'
    Console.WriteLine("SubStrings Count: " & btFormat.SubStrings.Count)

    ' Iterate through and read each SubString Name, Type and Value.'
    For Each substring As SubString In btFormat.SubStrings
    Console.WriteLine("SubString Name: " & substring.Name & ", SubString Type: " & substring.Type & ", SubString Value: " & substring.Value)
    Next substring

    ' Set a SubString Value using its index.'
    btFormat.SubStrings(0).Value = "New SubString Value"

    ' Set a SubString Value using its name (case sensitive).'
    btFormat.SubStrings("SubString1").Value = "New SubString Value"

    ' Close the current format without saving.'
    btFormat.Close(SaveOptions.DoNotSaveChanges)

    ' Stop the BarTender print engine.'
    btEngine.Stop()
    End Using
    End Sub
    [/code]

    Also, Substrings.GetAll() will returns list of all pairs of substring name and value in one string with specified delimiter.
    0

Please sign in to leave a comment.