Re: new line character in a string



wizard.fred@xxxxxxxxx wrote:
...

Needo wrote:

I have tried using \n as newline character in a PS string but when i use
show operator to draw the string then newline doesnt work.

(abc\n mnm) show
I get the folling output
abc mnm

is there any other mechanism to use newline character in a PS string ?

No, you need to show two separate strings and position them individually.
The show operators in PostScript don't have any newline feature.

Helge

...

I think it would be possible of constructing a procedure that would
parse the line(s) and create a line break at that point. Similar to
the automatic book printing ones that do automatic justification and
pagination.


Maybe this will give the OP some clues on the construction of such a function:

%!-Adobe-1.0
%%Title: asciiprint.ps
%%Creator: Ben Cranston
%%CreationDate: Thu Feb 8 1990
% http://www.wam.umd.edu/~zben/PostScript/asciiprint.html

/Courier findfont 10 scalefont setfont
/colwid (m) stringwidth pop def
36 756 moveto
256 string
{ %exec
{ %loop over file
dup currentfile exch readstring exch
{ %loop FF
(\f) search exch
{ %loop LF
(\n) search exch
{ %loop CR
(\r) search exch
{ %loop TAB
(\t) search exch
{ %loop BS
(\b) search exch
show
not { exit } if
pop currentpoint exch colwid sub exch moveto
} loop %BS
not { exit } if
pop currentpoint exch 36 sub colwid div .49 add cvi
8 add dup 8 mod sub colwid mul 36 add exch moveto
} loop %TAB
not { exit } if
pop 36 currentpoint exch pop moveto
} loop %CR
not { exit } if
pop 36 currentpoint exch pop
11 sub dup 25 le { %if
pop showpage 756
} if
moveto
} loop %LF
not { exit } if
pop showpage 36 756 moveto
} loop %FF
not { exit } if
} loop %over file
pop showpage
} bind exec
.



Relevant Pages

  • Re: HP laser ESC char font control
    ... and modify asciiprint.ps to replace the tab with dots up to the next column position. ... {%loop over file ... dup currentfile exch readstring exch ...
    (comp.unix.sco.misc)
  • Re: Get the path and namefile in run time
    ... function Get_Path_Only return String; ... -- This returns the first N characters of the program name. ... end loop; ...
    (comp.lang.ada)
  • Re: Parse String
    ... it picking up substrings beginning with 'f' followed by hyphens, ... Function gnaf(s As String) As Variant ... Exit Do 'inner Do ... Loop ...
    (microsoft.public.excel.programming)
  • Re: Newbie needs help
    ... You want to exit the loop when the user types ... void ParseLine (const string& cInput, ...
    (comp.lang.cpp)
  • Re: Ada Shootout program for K-Nucleotide (patches)
    ... - a loop reading input lines into an ... ubounded string replaces the recursive String "&"ing ... The following Getline has left me unconvinced. ... exit when Last = Item'Last; ...
    (comp.lang.ada)