none
Filter error RRS feed

  • Question

  • Hi,

    I am currently working on a filter for my program.

    If text is typed in a textbox, the check has to start.

    After this it resets the text in the textbox if the entered character was wrong or does nothing if the entered character was ok.

    This works so far. But only for the first character in the text. After this everything (even the not supported characters) are ok.

    In my code, only the numbers 0 1 2 3 4 5 6 7 8 9 are supported.

    How can I fix this? I can't find my mistake.

    My code:

    pv = ""
    For i = 1 To 10
        e = 47+i 'UNI-CODE
        goodlets[i] = Text.GetCharacter(e)
    EndFor
    
    Sub TT
      LTT = Controls.LastTypedTextBox
      If LTT = PVtb Then
        pv = Controls.GetTextBoxText(PVtb)
        start = Text.GetLength(pv)
        checklet = Text.GetSubTextToEnd(pv, start)
        For i = 1 To Array.GetItemCount(goodlets)
          If checklet = goodlets[i] Then
            reset = Text.Append(reset, 0)
          Else
            reset = Text.Append(reset, 1)
          EndIf
          'TextWindow.WriteLine(Text.Append(checklet, Text.Append("    ", reset))) 'DEBUG
        EndFor
        If Text.GetIndexOf(reset, 0) = 0 Then
          Controls.SetTextBoxText(PVtb, pvold)
          GraphicsWindow.ShowMessage("Only numbers and one point are allowed.", progtitle)
        Else
          TextWindow.WriteLine("The letter is ok!")
        EndIf
      EndIf
    EndSub


    Mit freundlichen Grüßen Timo Greetings Timo


    • Edited by Timo Sö Wednesday, April 23, 2014 4:51 PM
    Wednesday, April 23, 2014 4:50 PM

Answers

  • Timo,

    After trying to test your PLG039 (which is too complicated to test), I concentrated in your TT-sub.

    You still have to have a reset="" inside this subroutine, the line in GraphicWin in not sufficient. It works then better but not good. When pvold is written in the textbox, the cursor is in front  of the text, so the next character is added at he beginning instead of at the end.


    Jan [ WhTurner ] The Netherlands



    • Edited by WhTurner33Editor Tuesday, April 29, 2014 11:48 AM added text about cursor.
    • Marked as answer by Timo Sö Wednesday, April 30, 2014 4:23 PM
    Tuesday, April 29, 2014 11:13 AM
    Answerer
  • Maybe take a look here

    Define a TextBox with allowed Character

    or here

    Need a soultion/another way

    You can use LDControls.SetCursorPosition or LDControls.SetCursorToEnd or look in LitDev's 'Controls.cs' source and add a function to your own extension.


    • Edited by Pappa LapubEditor Tuesday, April 29, 2014 12:38 PM
    • Marked as answer by Timo Sö Wednesday, April 30, 2014 4:23 PM
    Tuesday, April 29, 2014 12:38 PM
    Answerer

All replies

  • Timo,

    Your snippet is to short to run, but I observed why the second letter checks Ok after a good one:

    "reset" is not reset. After the first check "reset" contains a 0, the second check adds all 1's to it,

    BUT "reset" still contains a 0 from the first check. 

    Add     reset="" before     For i=1 to Array.GetItemCount(goodlets)


    Jan [ WhTurner ] The Netherlands

    Wednesday, April 23, 2014 5:44 PM
    Answerer
  • I did this. I am sorry that I forgot to add it to my code above.

    Here you can find the whole code: PLG039


    Mit freundlichen Grüßen Timo Greetings Timo

    Wednesday, April 23, 2014 9:10 PM
  • Timo,

    After trying to test your PLG039 (which is too complicated to test), I concentrated in your TT-sub.

    You still have to have a reset="" inside this subroutine, the line in GraphicWin in not sufficient. It works then better but not good. When pvold is written in the textbox, the cursor is in front  of the text, so the next character is added at he beginning instead of at the end.


    Jan [ WhTurner ] The Netherlands



    • Edited by WhTurner33Editor Tuesday, April 29, 2014 11:48 AM added text about cursor.
    • Marked as answer by Timo Sö Wednesday, April 30, 2014 4:23 PM
    Tuesday, April 29, 2014 11:13 AM
    Answerer
  • Maybe take a look here

    Define a TextBox with allowed Character

    or here

    Need a soultion/another way

    You can use LDControls.SetCursorPosition or LDControls.SetCursorToEnd or look in LitDev's 'Controls.cs' source and add a function to your own extension.


    • Edited by Pappa LapubEditor Tuesday, April 29, 2014 12:38 PM
    • Marked as answer by Timo Sö Wednesday, April 30, 2014 4:23 PM
    Tuesday, April 29, 2014 12:38 PM
    Answerer
  • Thanks for your tips. I will try them!

    Mit freundlichen Grüßen Timo Greetings Timo

    Wednesday, April 30, 2014 4:23 PM