Page 1 of 1

formatting text

Posted: Tue Aug 05, 2008 5:54 pm
by user#606
Your help please, would be greatly appreciated!

From a number of text fields I wish to build up a single document.
The main document might be built up in this way.
Item heading 1
Some descriptive text here from another variable in plain format.
Item heading 2
Some MORE descriptive text here from another variable in plain format.
and so on......
Whatever I try, I end up with either all bold and underlined
OR
plain text
but not bold underlined headings with plain text to follow.
There are no constant positions for the headings or set text length or content. They are derived from calculation elsewhere.

Code used:



global Secondary
put empty into field "tmptext"
put empty into field "transf"
put empty into ConstructionSummary
set the textstyle of field "tmptext" to "underline, bold"
set the textstyle of field "transf" to "plain"

put "Main Heating system " into field "tmptext"
put BoilerText into field "transf"
put field "tmptext" & return & field "transf" into ConstructionSummary

put "Heat emitters " into field "tmptext"
put EmitterTxt into field "transf"
put ConstructionSummary & return & field "tmptext" & return & field "transf" into ConstructionSummary

put "Secondary Heating system" into field "tmptext"
put Secondary into field "transf"
put ConstructionSummary & return & field "tmptext" & return & field "transf" into ConstructionSummary

put ConstructionSummary into field "tmptext"

Posted: Tue Aug 05, 2008 7:39 pm
by Mark
Hi user,

What about something like:

set the htmlText of fld A to (the htmlText of fld x & the htmlText of fld y & the htmlText of fld z)

Best,

Mark

Posted: Wed Aug 06, 2008 7:35 am
by user#606
I have tried that already, but it did not work, I do read up in the manual and posts (where I saw this example) and SATSOT.
I cannot see why the formatted text in my code fails to do what is intended. After all, I am only adding text in steps to a container that can accept the different formats.

Posted: Wed Aug 06, 2008 8:25 am
by Klaus
Hi user#606,

in a quick test, this does work for me, collecting all the HTMLtext in one variable:

Code: Select all

on mouseUp
  put the htmltext of fld 1 & CR & the htmltext of fld 2 into harold
  set the htmltext of fld 3 to harold
end mouseUp
Best

Klaus

Posted: Wed Aug 06, 2008 9:14 am
by Mark
User,

Your script moves text around and leaves behind any text styles. The "put" command only deals with plain text. There is no way for your script to preserve text styles. Try using the htmlText again and if it doesn't work, please post your script here.

Best,

Mark

Posted: Wed Aug 06, 2008 9:22 am
by user#606
Hi Mark,
I have tried the suggestion from Klous, but, you are right, it is plain text with text styles.
<p><p>&lt;p&gt;&lt;/p&gt;</p></p>
<p><p>&lt;p&gt;Main Heating system &lt;/p&gt;</p></p>
<p><p>&lt;p&gt;Natural gas, Condencing, Combi boiler with fan assisted balanced flue and auto ignition, having a

It appears odd to me that such a simple and probably typical way of building up headed paragraphs is so problematic.

the complete code is:
ON mouseUp

local filepath
global ConstructionSummary
global CylHeatSpace, CylinderSpec
global BoilerText
global SizeFlag
global BoilerChoice
global LPGflag
global EmitterTxt
global Cylinder
global Secondary
put empty into field "tmptext"
put empty into field "transf"
put empty into ConstructionSummary
put empty into field "ConstructionSummary"
set the textstyle of field "tmptext" to "underline, bold"
set the textstyle of field "transf" to "plain"

put "Main Heating system " into field "tmptext"
put BoilerText into field "transf"
put the htmltext of field "ConstructionSummary" & return & the htmltext of field "tmptext" & return & the htmltext of field "transf" into field "ConstructionSummary"

put "Heat emitters " into field "tmptext"
put EmitterTxt into field "transf"
put the htmltext of field "ConstructionSummary" & return & the htmltext of field "tmptext" & return & the htmltext of field "transf" into field "ConstructionSummary"

put "Secondary Heating system" into field "tmptext"
put Secondary into field "transf"
put the htmltext of field "ConstructionSummary" & return & the htmltext of field "tmptext" & return & the htmltext of field "transf" into field "ConstructionSummary"

put field "ConstructionSummary" into field "tmptext"
go to card id 1087
END mouseUp

--put the htmltext of fld 1 & CR & the htmltext of fld 2 into harold
--set the htmltext of fld 3 to harold

Posted: Wed Aug 06, 2008 11:47 am
by Mark
Dear User,

Please read the information about htmlText in the docs. I can't possibly explain it better.

Whenever you put text into a field, you get plain text. After doing so, you must set the textStyle of char a to b of fld X to whatever style you want. Setting the textStyle of a field doesn't change the text itself and setting the textStyle of a text before putting the text into the field... well... just doesn't make any sense. Make sure to read about the textStyle property in the docs as well.

Best,

Mark

Posted: Wed Aug 06, 2008 12:27 pm
by user#606
Mark,
What you say appears to be the reality of the situation, however something is odd here.
If you look at the contents of a field variable, you can actually select some of it and set its properties to BOLD, for example. When displayed, those properties remain, even if more text is added (albeit plain).
My requirement is so basic to any language, that I cannot believe it cannot be done as I want without complex string manipulation.

Posted: Wed Aug 06, 2008 12:39 pm
by Mark
Hi User,

If a field already contains text, you can put plain text after it, using

put "some text" after fld x

This will preserve already existing text properties.

If you want something else, you need to apply a little bit of very simple text manipulation. Fact is, as long as you're not using unicode, this works much simpler than with most other languages.

Best,

Mark