Hello,
to write free text in "old"-4JS BDL we used an input array with f.e. 60 Characters per line.
Each row in the array we stored as 1 row in a table.
In many Reports we printed each row of this table with 60 Characters.
No I want to use the textedit field instead of an Array.
I definded a string-variable and read the text from the table and append it to the string.
After each row I added an ascii 10 to have the same Text-Layout as before in the array.
The per file is using a fixed Fontpitch, so I can only use 60 Characters per Line.
That works very fine.
But now I wrtie a new text. At the end of the line a new word is beginning at at next line (without CR) ....
When I save the Text in the table I must be able to split the text after 60 Character, but at lines with "Word-Wrap" the "Blanks" at the end of the lines where clipped. So the 60 charactrers has the Information from 2 lines of from my Screen, but 2 Lines on the screens must be to lines in the table.
I hope you understand my problem.
Has anyone an idea for me
thanks in advance
Stefan Serwe
Stefan,
you just need to create a routine that splits the text something like:
define txt string, line char(60), more char
.
.
-- Before inserting
call split_text(txt, 60) returning txt, line, more
while more -- or whatever
insert into ......
call split_text(txt, 60) returning txt, line, more
end while
Hope this helps,
-Snorri
Thanks Snorri,
but splitting the text after 60 characters ist not the problem
I attached a hardcopy to sh my problem.
In this case I need to create 2 Lines in my table.
Stefan,
maybe the solution is in the "wrapPolicy" TextEdit style Attribute.
set it to "anywhere" then GDC will wrap your text after 60 characters, then you will see in the first line "12...WORD" and in the second "WRAP" instead of "12...90" and "WORDWRAP".
<Style name="TextEdit">
<StyleAttribute name="wrapPolicy" value="anywhere" />
</Style>
Stefan, you just need to check in your routine if the user has enetered <LF>
We actually have a routine that works:
function split_text(text,blen)
define
text varchar(10000),
blen,tlen,i integer
if blen <= 1 then
return text clipped,null -- Illegal length
end if
let tlen = length(text)
------------------------------------------------------------------
-- Do we get an EOL within our split?
------------------------------------------------------------------
for i = 1 to minint(blen + 1,tlen) step 1
if text[i,i] = "\n" then
case
when tlen = 1 return null,null
when i = 1 return null,text[i+1,tlen] -- First char is EOL
when i = tlen return text[1,i-1],null -- Last char is EOL
otherwise return text[1,i-1] clipped,text[i+1,tlen] -- Line fits
end case
end if
end for
------------------------------------------------------------------
-- Check if last split
------------------------------------------------------------------
if tlen <= blen then
return text clipped,null
end if
------------------------------------------------------------------
-- Check if we need to split words
------------------------------------------------------------------
for i = minint(blen + 1,tlen) to 1 step -1
if text[i,i] = " " then
case
when i = 1 return null,text[i+1,tlen] -- First char space
when i = tlen return text[1,i-1],null -- Last char space
otherwise return text[1,i-1] clipped,text[i+1,tlen] -- Line split
end case
end if
end for
------------------------------------------------------------------
-- We need to split within a word
------------------------------------------------------------------
return text[1,blen],text[blen+1,tlen]
end function
function minint(val1,val2)
define val1,val2 integer
case
when val1 is null return val2
when val2 is null return val1
when val1 < val2 return val1
otherwise return val2
end case
end function
split_returns null if it finished so you can use this in a loop like:
while nigsamn.aths is not null
call split_text(nigsamn.aths,76) returning rep,nigsamn.aths
if rep is not null then
call reportput(rep)
let icnt = icnt + 1
end if
end while
OK many Thanks for the tipps
Reply 3:
it works fine, but if I want to copy a text from a document and paste it into the 60-Characters textedit field there is a lot of work to correct the layout of the thext.
Reply 4:
This is excactly what I want to do. Great.