How to handle text (or chunk?) formatting?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mluka
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 73
Joined: Sun Jun 17, 2007 12:08 am
Location: Montréal, Canada

How to handle text (or chunk?) formatting?

Post by mluka » Tue Jul 10, 2007 3:15 am

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.)
Michel
Montréal, Canada

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Tue Jul 10, 2007 6:33 am

Hi mluka,

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"
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.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

xApple
Posts: 113
Joined: Wed Nov 29, 2006 10:21 pm
Location: Geneva

Post by xApple » Tue Jul 10, 2007 4:03 pm

[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:

Code: Select all

set the htmltext of field c to (the htmltext of field a & the htmltext of field b)
Then to print, you shouldn't have too much problems. Or at least, you shouldn't have problems related to the formating.

Cheers.

mluka
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 73
Joined: Sun Jun 17, 2007 12:08 am
Location: Montréal, Canada

Text formatting

Post by mluka » Wed Jul 11, 2007 4:46 am

Thanks for your suggestions.
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 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.
Code:
set the htmltext of field c to (the htmltext of field a & the htmltext of field b)
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!

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

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Wed Jul 11, 2007 11:54 am

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?

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
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”