• Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

Field variables with carriage return

Mike Mackinnon

Well Known Member
Does anybody know how to deal with carriage returns in a field? I have an application that allows users to enter text into a field up to 2000 characters (multiple lines). I am using a single DD item to capture all 2000 characters. The problem is that when I go to display the lines on a UBE report I get unpredictable results due to (I think?) the carriage returns entered by the user. Does anyone know how I can avoid this?

Mike MacKinnon
One World B733, SP 11.3 (This time)


- One World B733, SP 11.3
- One World Xe B7333, SP 13 Windows NT
 
Mike,

I had a similar problem with a UBE printing attachments. The information
appearing after the attachment had to print in exactly the same position
regardless of the carriage return. There was no apparent method of finding a
Carriage return in Named Event Rule code. The problem was overcome by
creating a C business function that passed in the free form text and
returned fields in separate lines. You can create the bulk of the code in a
NER business function and copy the C code generated by the NER into the C
business function. To capture the carriage return in the C business function
do a comparison between each character in the text and '\r'.

Paul Pannu

One World B733
 

Zoltan_Gyimesi

Legendary Poster
Mike,
I really do not know that my suggestion could help you but so simply to try it at your site that I decided that I will post it.

Try to enter the new line (carriage return?) characters with CTRL-ENTER key stroke instead of as a simple ENTER on your entry form and after it run your report to see the result.

Please, let us know your results. Thanks.

Zoltán


B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)
 

Mike Mackinnon

Well Known Member
Thanks for the idea Zoltan.
I have done a quick test and this seems to work. I am curious as to how I can get users to enter a CTRL-ENTER when they are keying information into a long field on the entry screen. Maybe there is some way to get them to use the CTRL key when entering a carriage return, maybe a post-it note on the terminal. :) Well this is better than it was before so we can at least see all characters on the report. Thanks again.

- One World B733, SP 11.3
- One World Xe B7333, SP 13 Windows NT
 

Zoltan_Gyimesi

Legendary Poster
Hi Mike,
I really did not know that my suggestion will work or won't, so I am very happy that it does work.
About forcing to enter CTRL-ENTER:

I think, you have other and better choice:
Replace the "ENTER" characters with "CTRL_ENTER" in the ControlIsExitedANdChanged event. You will need to create one or two work variable based on the same data item as your control has. Move the characters one by one extracting them with "substring" and using a running index variable, compare them and replace when it needed. You can use also the "length" function to control the length in your WHILE loop.
The best way to write a C or NER Business Function for this like "ReplaceCharInString" with four or five parameter: InputString, OutputString, CharToReplace, CharWithReplace, Occurences (optional output information).
Before you begin to do this, you have to figure out that wich is the character that entered by ENTER and by CTRL-ENTER. If you have trouble to guess it then let us know, I am sure that you will get help. Further problem could be when you want to make the replace with NER code, how to use this Character Code. Let us know also when you need further help.
Unfortunately, next week I will be at one of our clients, hope I will have some minutes to watch the Forum and reply briefly.

Good Luck and do not forget to shar your results with us.
Thanks,
Zoltán




B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)
 
Top