Custom Textfield: Join custom Text() Property

  1. 4 years ago

    Martin T

    17 Jan 2016 Pre-Release Testers Germany

    Hi,

    I created a custom Textfield with a Text-Array "mErrors". After validating, i wanna show a Messagebox with all Errors. Because of the main Text Property of Textfield the following Code is not working. How to fix ist?

    Dim mErrors() As Text = Array("First Error", "Second Error")
    Dim mOutput As Text = Text.Join(mErrors, EndOfLine.Operator_Convert.ToText)
    
    MsgBox mOutput
  2. Greg O

    17 Jan 2016 Xojo Inc scout.galaxy.barn

    What is the error?

  3. Martin T

    17 Jan 2016 Pre-Release Testers Germany

    Type "String" has no member named "Join"

    Text.Join thinks i mean Textfield.Text, but i mean Text.Join

  4. Michel B

    17 Jan 2016 Pre-Release Testers, Xojo Pro
    Edited 4 years ago

    What is Text() ?

  5. Martin T

    17 Jan 2016 Pre-Release Testers Germany
    Edited 4 years ago

    @Michel B What is Text() ?

    Text is the Text Type of the new Xojo Framework (look at the Join sample at the End)

  6. Michel B

    17 Jan 2016 Pre-Release Testers, Xojo Pro

    I already encountered last week an issue with EndOfLIne, which appears not to be a string, but to be a class. So ToText does not work.

    I think it is necessary to go through an intermediate string, such as :

      Dim endof as string = EndOfLine
      dim EOL as Text = endof.ToText
      Dim mErrors() As Text = Array("First Error", "Second Error")
      Dim mOutput As Text = Text.Join(mErrors, EOL)
  7. Martin T

    17 Jan 2016 Pre-Release Testers Germany

    It's not working. Try by yourself:

    1. create Subclass "Test" of TextField
    2. add Property mErrors() As Text
    3. add some Entries to mErrors
    4. try your Code

    Text.Join thinks, Text = TextFields.Text, but it is Text of new Framework :/

  8. Will S

    17 Jan 2016 Answer Santa Cruz 

    This is a naming conflict and I don't see a way to specify the Text type over the Text property.

    You could create your own Join wrapper for Text type in a Module.

    Function Join(extends items() As Text, seperator As Text) As Text
      return Text.Join(items, seperator)
    End Function

    Use like

    Dim mOutput As Text = mErrors.Join(EndOfLine.Operator_Convert.ToText)
  9. Martin T

    17 Jan 2016 Pre-Release Testers Germany

    Thanks Will and Michael, that's a working Solution for me.

  10. Michel B

    17 Jan 2016 Pre-Release Testers, Xojo Pro

    @MartinTrippensee Text.Join thinks, Text = TextFields.Text, but it is Text of new Framework :/

    You are right, the compiler does think Text is the string property.

    I would try creating the class on a ContainerControl so the confusion could not happen, since TextArea would be just a control, and the code would be attached to the ContainerControl.

or Sign Up to reply!