How to handle text (or chunk?) formatting?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 73
- Joined: Sun Jun 17, 2007 12:08 am
- Location: Montréal, Canada
How to handle text (or chunk?) formatting?
Hi, all.
I need to fill a field with elements coming from various sources: some words will get put into the fld as a result of a button having been clicked. Other words may be added to the field from typing at the keyboard.
Still other words may be added to the field from an external database (maybe FileMaker Pro, using ODBC, maybe mySQL). Some of those words may have been formatted as bold or italic or underlined. Or they may be just plain.
In order to preserve the formatting of the chunks coming from those various sources, what commands, properties, functions, etc. should I be using???
Is there any simple way such as "put field "B" after field "A""? (I already know that this doesn't work...)
Sub-question: once I have filled up field "A" would I be able to print it with all the formatting or would that be another problem altogether?
Thanks!
("... 7 days remaining in your trial.)
I need to fill a field with elements coming from various sources: some words will get put into the fld as a result of a button having been clicked. Other words may be added to the field from typing at the keyboard.
Still other words may be added to the field from an external database (maybe FileMaker Pro, using ODBC, maybe mySQL). Some of those words may have been formatted as bold or italic or underlined. Or they may be just plain.
In order to preserve the formatting of the chunks coming from those various sources, what commands, properties, functions, etc. should I be using???
Is there any simple way such as "put field "B" after field "A""? (I already know that this doesn't work...)
Sub-question: once I have filled up field "A" would I be able to print it with all the formatting or would that be another problem altogether?
Thanks!
("... 7 days remaining in your trial.)
Michel
Montréal, Canada
Montréal, Canada
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Hi mluka,
You can set the 'textStyle' property of individual chunks:
Or, you can play with the 'htmlText' property of the field to achieve the same result by inserting <b>...</b> tags in the proper places.
When you're working with data from external databases, it's important to know how this data is formatted. Rev can handle a subset of html and rtf in its fields, so if your stack is a front-end to a database, you can save the style information by saving the 'htmlText' property of your field instead of the 'text' property of the field.
Hope this helped,
Jan Schenkel.
You can set the 'textStyle' property of individual chunks:
Code: Select all
set the textStyle of word 2 of line 3 of field "foobar" to "bold,italic"
When you're working with data from external databases, it's important to know how this data is formatted. Rev can handle a subset of html and rtf in its fields, so if your stack is a front-end to a database, you can save the style information by saving the 'htmlText' property of your field instead of the 'text' property of the field.
Hope this helped,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
[put field "B" after field "A"] is a valid command all-though it doesn't conserve the formatting. To conserve formating you could use the following command to put 2 fields together:
Then to print, you shouldn't have too much problems. Or at least, you shouldn't have problems related to the formating.
Cheers.
Code: Select all
set the htmltext of field c to (the htmltext of field a & the htmltext of field b)
Cheers.
-
- Livecode Opensource Backer
- Posts: 73
- Joined: Sun Jun 17, 2007 12:08 am
- Location: Montréal, Canada
Text formatting
Thanks for your suggestions.
I tried using the RTFText property, instead of htmlText. This also works, but this time, the new text gets appended right at the end of the original text, but NOT on a new line!
Weird, eh?
Anyway, in conclusion: it's possible, when going from field to field, in RR, to preserve the formatting.
I've started trying to to do the same thing with data in an external database (FileMaker, using RR's revDataFromQuery function), but have not suceeded yet. The text seems to be stripped of its formatting. Maybe I'm not using the right function???
Any ideas?
And thanks for your help so far! I appreciate it.
("... 6 days remaining in your trial.)
This is NOT what I want to do: the Filemaker database already contains some formatted text; all I want to do is use the data, in RR, with its original formatting.You can set the 'textStyle' property of individual chunks:
Code:
set the textStyle of word 2 of line 3 of field "foobar" to "bold,italic"
Or, you can play with the 'htmlText' property of the field to achieve the same result by inserting <b>...</b> tags in the proper places.
This works. But with a weird side effect: the new text (the htmltext of fld B) gets added to the end of fld A, but on a new line!Code:
set the htmltext of field c to (the htmltext of field a & the htmltext of field b)
I tried using the RTFText property, instead of htmlText. This also works, but this time, the new text gets appended right at the end of the original text, but NOT on a new line!
Weird, eh?
Anyway, in conclusion: it's possible, when going from field to field, in RR, to preserve the formatting.
I've started trying to to do the same thing with data in an external database (FileMaker, using RR's revDataFromQuery function), but have not suceeded yet. The text seems to be stripped of its formatting. Maybe I'm not using the right function???
Any ideas?
And thanks for your help so far! I appreciate it.
("... 6 days remaining in your trial.)
Michel
Montréal, Canada
Montréal, Canada
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
It could be that FileMaker stores the style information in a separate column of the table; one that is not accessible from the outside. What happens when you use the following code to extract all the column names of a table?
Jan Schenkel.
Code: Select all
function AllTableColumnNames pConnectionID, pTableName
put "SELECT * FROM" && pTableName into tQuery
put revdb_query(pConnectionID, tQuery) into tCursorID
if tCursorID is not a number then
answer error tCursorID with "Cancel"
exit to top
end if
put revdb_columnnames(tCursorID) into tColumnNames
get revdb_closecursor(tCursorID)
return tColumnNames
end AllTableColumnNames
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com