-1

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

XLD_a
  • 195
  • 1
  • 4
  • 16

2 Answers2

2

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
  • I suggest to use Replace( ) and Pos( ) instead of ReplaceA( ) and PosA( ) since PB is using Unicode internally since PB 10. – MicKr- Sep 14 '17 at 09:55
0

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.