simona
7th January 2010, 11:39
Hello there!
...And happy new year 2010!!
I have a text field in a report. I seted the lenght to 20 characters and the text is wrapped by this lenght. But I want to do the wrapping by words, see attached file. How can I do this?
Thanks!
Sim
NirajKakodkar
8th January 2010, 18:52
Hey Simona ,
What I can suggest you is to write your own function to wrap the text the way you want . I dont think there is some predefined function for this .
I remeber I had done something like this in my previous company , will post if I find the code .
Best Regards,
Niraj
BeznaWarrior
19th January 2010, 14:52
Hi Simona,
I've looked over your problem and i've managed to write a function that overwrites the text field with the new wrapped text.
As you might know the text fields are located in tool table tttxt010.So here goes the function:
function extern tcitc.dll0002.wrapptext(domain tttxt.ctxt ctxt,domain ttaad.clan clan, long rand) where
ctxt is the text number from tttxt010.ctxt
clan is the language field from the same table
and rand is the lenght of the row (in your example 20)
You take the text field and search word by word (you search with pos function like pos(tttxt010.text , " ")) and you handle various cases that appear: is it the last word from text (the call of pos function returns 0) or the word is bigger than the lenght of the row (in your case 20 char) or any other possible case.
Every time you have to jump to another row you concatenate your new text with "line feed" char (for that you can use chr$(10) )
I hope i've managed to help you.If you still have trouble please ask....
function extern tcitc.dll0002.wrapptext(domain tttxt.ctxt ctxt,domain ttaad.clan clan, long rand)
{
select tttxt010.*
from tttxt010
where tttxt010._index1 = {:ctxt, :clan}
selectdo
old.text = tttxt010.text
new.text = ""
aux = old.text
lung = len(shiftl$(shiftr$(old.text)))
flag = 1
while shiftl$(shiftr$(old.text))<>""
if pos(old.text, " ")>rand then |the word is longer than the row
flag = 1
new.text = new.text&chr$(10)&old.text(flag;rand)&chr$(10)
lung = lung - rand
old.text = old.text(rand+1;lung)
else
if pos(old.text, " ")=0 then |last word
cuv = len(old.text)
if cuv+flag<=rand then
new.text = new.text&old.text(1;cuv)
else
new.text = new.text&chr$(10)&old.text(1;cuv)
endif
old.text = ""
else
cuv = pos(old.text," ")
if cuv+flag<=rand then |length of word + position on the row is smaller than the row
new.text = new.text&old.text(1;cuv)
if lung<cuv then
lung = 0
else
lung = lung - cuv
endif
old.text = old.text(cuv+1; lung)
flag = flag+cuv
else
new.text = new.text&chr$(10)&old.text(1;cuv)
lung = lung-cuv
flag = cuv
old.text = old.text(cuv+1; lung)
endif
endif
endif
endwhile
db.retry.point()
select tttxt010.*
from tttxt010 for update
where tttxt010._index1 = {:ctxt, :clan}
selectdo
indice = tttxt010.text
tttxt010.text = new.text
db.update(ttttxt010, db.retry)
endselect
commit.transaction()
endselect
}
cherokee
23rd June 2010, 20:46
I have a text field on my report and I have not enough space to put 72 columns for the text, I have 38. I kind of remember that BaaN will put the rest of the line on the following report line. Am I right? or how this works?
Thanks in advance,