Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Quick print question

 [1/5] from: chalz::earthlink::net at: 6-Apr-2002 23:21


Without having to reference docs (it's not actually that important - I'm simply curious) is there a quick and easy way to print separate lines? For instance, in the cases of: text: [ "line 1" "line 2" "line 3" ] Or text: { line 1 line 2 line 4 } Some method such as print/lines text to output each line (either EOL character, CR/LF, etc) without using a for-style loop. (for-looping becomes an issue with the {} style, since you can't just say "foreach line text"...) Thanks folks. --Charles

 [2/5] from: anton:lexicon at: 7-Apr-2002 18:01


It is unclear exactly what you want Charles, but perhaps this will do the trick. print-lines: func [blk [block! string!]][ if string? blk [blk: parse/all blk "^/"] foreach line blk [print line] ]
>> print-lines ["line 1" "line 2" "line 3"]
line 1 line 2 line 3
>> print-lines {line 1^/line 2^/^/"line 4"}
line 1 line 2 line 4 <- notice the quotes are gone, however. Anton.

 [3/5] from: joel:neely:fedex at: 7-Apr-2002 7:23


Hi, Charles, Charles wrote:
> Without having to reference docs (it's not actually that > important - I'm simply curious) is there a quick and easy way
<<quoted lines omitted: 8>>
> line 2 > line 4 }
I'll comment in passing that this abstraction seems a bit strange to me, since a block of strings is a container of containers of characters and a string is a container of characters. IOW, this abstracts over depth of nesting rather than over data type. That said... print-as-lines: func [c [string! block!]] [ foreach line either block? c [c] [parse/all c "^/"] [ print line ] ] shoud do what you asked. -jn- -- ; Joel Neely joeldotneelyatfedexdotcom REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] { | e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]

 [4/5] from: chalz:earthlink at: 9-Apr-2002 16:59


Cool. Thanks Joel, Anton. I ended up reading the entire {} group one character at a time, because I ultimately limited the length of output lines to 75 characters per line, along with a header character at the beginning of each line. By the by, what's "IOW" in this context mean?

 [5/5] from: greggirwin:mindspring at: 10-Apr-2002 9:51


Hi Charles, IOW = In Other Words --Gregg

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted