I'm using a BBScrollingLabel in a B4J Application where a user enters a formatted text string in a textbox (txtInpup.text) and displays the string in a scrolling label:
Works great. If the user enters an input string - For example :
"This is [colour=red] RED [/colour] and not BLACK"
(note: I purposely spelt color with a u in this post to suppress the formatting of the tags in this message. But it's actually "color" and not "colour" in my code )
It displays "This is RED and not BLACK" correctly
However, if the user enters a bad tag. For example - [/c] instead of [/colour]
"This is [colour=red] RED [/c] and not BLACK"
The program will crash with the message:
Error (position - 40): Closing tag does not match: c
Error occurred on line: 184 (BBCodeParser)
java.lang.RuntimeException: Object should first be initialized (List).
OK.. so I can trap the error using "Try-Catch" -
But once an error is trapped, on the next go-around, when the user tries to enter the corrected test string, - "This is [colour=red] RED [/colour] and not BLACK"
it appears that "BBScrollingLabel1.Text" has retained the previous value ( with the /c" tag) and the error gets trapped again with the same error message
Error (position - 40): Closing tag does not match: c.
Error occurred on line: 184 (BBCodeParser)
java.lang.RuntimeException: Object should first be initialized (List).
No matter what the user types in, an error is trapped and the above message is displayed until the program is restarted and a valid string is entered.
Is then any way to "clear" BBScrollingLabel1.text after an error is trapped? I tried reinitializing in the "Try-catch" section:
But that causes another crash.
Any thoughts?
Thanks!
B4X:
TextEngine.Initialize(MainForm.RootPane)
BBScrollingLabel1.TextEngine = TextEngine
smsg = txtInput.text
BBScrollingLabel1.Text = $"${smsg}"$
Works great. If the user enters an input string - For example :
"This is [colour=red] RED [/colour] and not BLACK"
(note: I purposely spelt color with a u in this post to suppress the formatting of the tags in this message. But it's actually "color" and not "colour" in my code )
It displays "This is RED and not BLACK" correctly
However, if the user enters a bad tag. For example - [/c] instead of [/colour]
"This is [colour=red] RED [/c] and not BLACK"
The program will crash with the message:
Error (position - 40): Closing tag does not match: c
Error occurred on line: 184 (BBCodeParser)
java.lang.RuntimeException: Object should first be initialized (List).
OK.. so I can trap the error using "Try-Catch" -
B4X:
smsg=txtinput.Text
Try
BBScrollingLabel1.Text = $"${smsg}"$
Catch
Log("Invalid tag in message")
End Try
But once an error is trapped, on the next go-around, when the user tries to enter the corrected test string, - "This is [colour=red] RED [/colour] and not BLACK"
it appears that "BBScrollingLabel1.Text" has retained the previous value ( with the /c" tag) and the error gets trapped again with the same error message
Error (position - 40): Closing tag does not match: c.
Error occurred on line: 184 (BBCodeParser)
java.lang.RuntimeException: Object should first be initialized (List).
No matter what the user types in, an error is trapped and the above message is displayed until the program is restarted and a valid string is entered.
Is then any way to "clear" BBScrollingLabel1.text after an error is trapped? I tried reinitializing in the "Try-catch" section:
B4X:
TextEngine.Initialize(MainForm.RootPane)
BBScrollingLabel1.TextEngine = TextEngine
But that causes another crash.
Any thoughts?
Thanks!