Carriage return in code

nickree

New Member
Hi

I am extracting some addresses in syteline with progress and would like to know how to put in a std carriage return to start next line of address

Thanks
 

joey.jeremiah

ProgressTalk Moderator
Staff member
Code:
message "hello~nworld" view-as alert-box.

this way lets you insert newlines into strings.

"~n" equals to chr(10), take a look at special characters in the online help (f1).


Code:
put "hello" skip "world".

you could also use skip with put, display, or use down frames. hth
 

TomBascom

Curmudgeon
Carriage Return = CR = Control-M = chr(13)
Line Feed = LF = Control-J = chr(10)

"New Line" = ~n ("~" is the Progress operating system independent syntax for a special character.)

The actual value that a statement such as PUT "~n" will use depends on the operating system in use. For UNIX it is a line feed. For Windows it is a carriage return plus a line feed. On a Mac it is a carriage return (Oops! Progress doesn't run on Macs... :eek: ). Check this out for more detail than you could possibly want:

http://en.wikipedia.org/wiki/Newline

Anyhow...

You say that you are "extracting" some data and want to separate it with what sounds like a new line.

What form are you putting this data in? Are you extracting it to a file or to the screen? Or are you putting into an editor widget?

For most purposes in a Progress program you probably want to use SKIP syntax or, as Joey indicates, a DOWN frame rather than embedding the control character.
 

joey.jeremiah

ProgressTalk Moderator
Staff member
turns out theres a little more to it, at least then i first thought.

i wrote a couple short test scripts, heres what came back, using openedge 10.0b gui -

Code:
 message length( "~n" ) asc( "~n" ) view-as alert-box.
returns length 1 and chr(10)



Code:
define var pBuffer  as memptr no-undo.
define var str      as char no-undo.
define var i        as int no-undo.



/* create test file */

output to test.prn /*** binary no-convert */ .

    put unformatted "~n".

    /* put skip(1). */

output close.



/* read test file */

set-size( pBuffer ) = 1000.

input from test.prn binary no-convert.

    import pBuffer.

    str = get-string( pBuffer, 1 ).

input close.

set-size( pBuffer ) = 0.



/* display file content */

repeat i = 1 to length( str ):

    display i asc( substr( str, i, 1 ) ).

end. /* repeat */
returns chr(13) and chr(10), and just chr(10) with binary no-convert, i got back the same results using put skip(1).

so, looks like chr(10) is converted to chr(13) and chr(10) when not outputing in binary mode, in windows.

oh, anyways absolutely use skip, or down frame *if you can* inserting "~n" is more of a hack.
 
Top