Hi,
I need to create a report with a justified text (as if it was made with Word).
I used the TEXT control on the report.
The text is dynamically created with the content of several fields.
How can be done?
Clarion 11.1 EE
TIA!
Hi,
I need to create a report with a justified text (as if it was made with Word).
I used the TEXT control on the report.
The text is dynamically created with the content of several fields.
How can be done?
Clarion 11.1 EE
TIA!
Can you define what you mean by “Justify”? I assume you do not mean left or right justified
Are you talking about “full”?
Hi,
Thanks for your reply!
Yes, I’m refering to full justify alignment, not left or right alignment.
I’m trying to directly print a contract, filled with the contractors data, calling a REPORT with a TEXT control and using a STRING variable with the full text.
There isn’t any formatting in the text (bold, italic, etc.), so no need to have a RTF control on a WINDOW before printing. Just plain text to print.
But I need the text to have full justified alignment…
I saw the RTF NotePad in the examples folder and could be a great solution. But I’m seeking something simpler…
You can use CENTER but I’m thinking you want the text evenly spread across the width, ie: increasing the space between words. I’m uncertain if that’s easily possible using Clarion without some add-on.
Hi,
Yes. This is exactly what I want…
Looking at the RTF NotePad example gave me some ideas about a posible solution using a hidden RTFTextControl control template and the RTFAction code template…
But I’d still prefer a simpler solution…
If you have a non-proportional font it makes this a lot easier, otherwise it’s a PITB. I’ve done similar, by using a separate hidden TEXT control to test the actual width. It might be simplest to do a string theory Split() to separate the words into a queue, but maybe not the most efficient way.
First you need to determine the number of spaces that you need to make up the width that you need to make the line ‘full’, using your particular font, etc.
Then divide that number of spaces into a separator string that can be used to re-join the split() string theory object.
Have a look at st.wrapText
It will get you around 75% there and leaves the lines in the lines queue
Then take each lIne in another st object and split on space. Pad as desired then rejoin and move back into the original line.
I am just on my phone boarding a plane but hopefully that gives you an idea. A few considerations when padding a line:
Only one word on line then left justify.
Only two words then left justify the first and right justify the second.
See how you go. I can help more from my destination!
Cheers
Geoff R
OK I have arrived and consumed some duty free Irish whisky to lubricate the synapses (so this is guaranteed to work first time, ha ha) and I am thinking maybe something like:
AlignText procedure(stringTheory pSt, long pWidth=80, bool pKeepExistingBreaks=true, bool pleft=false)
lne stringTheory
x long,auto
y long,auto
extraSpaces long,auto ! how many spaces we need to pad
appendSize long,auto ! number of extra chars between each and every word
remainder long,auto ! number of extra word gaps to be expanded
code
pSt.wrapText(pWidth, pKeepExistingBreaks, pleft)
loop x = 1 to pSt.records()
lne.setValue(pSt.getLine(x))
extraSpaces = pWidth - lne.len()
if extraSpaces < 1 then cycle. ! no need to expand
lne.split(' ')
if lne.records() = 1 then cycle. ! only one word on line
appendSize = extraSpaces / (lne.records() - 1)
remainder = extraSpaces % (lne.records() - 1)
loop y = lne.records()-1 to 1 by -1
if appendSize = 0 and remainder = 0 then break.
lne.setValueFromLine(y)
if remainder > 0
lne.adjustLength(appendSize + 1)
remainder -= 1
else
lne.adjustLength(appendSize)
end
lne.setLineFromValue(y)
end
lne.join(' ')
? assert(lne.len() = pWidth) ! are we good?
pSt.setLine(x, lne) ! replace expanded line
end
pSt.join('<13,10>') ! combine updated lines
let us know how you go or if you need any explanation
cheers again
Geoff R