How can I remove newline character from a string in powerbuilder? I have a column where I can write something and when I press enter it inserts a newline character. I want to remove it when I press save.
Thanks
How can I remove newline character from a string in powerbuilder? I have a column where I can write something and when I press enter it inserts a newline character. I want to remove it when I press save.
Thanks
To remove the Newline character...
ll_pos = PosA(ls_text, "~n")
do while(ll_pos > 0)
ls_text = ReplaceA(ls_text, ll_pos, 1, "")
ll_pos = PosA(ls_text, "~n")
loop
If you need to remove the Carriage Return as well...
ll_pos = PosA(ls_text, "~r~n")
do while(ll_pos > 0)
ls_text = ReplaceA(ls_text, ll_pos, 2, "")
ll_pos = PosA(ls_text, "~r~n")
loop
Another, completely different way to solve the problem is to make your Save
button a Default
button (third check box in the General
tab). This way, when the user presses Enter
, that button is actually activated. This prevents you from further processing. Of course, it remains to see if that behaviour is normal / desired.