PDA

View Full Version : Need Help with Multiple RTF files and the Rich Text Object


sue
02-03-2008, 07:32 AM
I really would appreciate your help to solve my dilemma --

1. What I have is a table named questions in a SQLlite database. The table has three columns - QuestionID, QuestionText and QuestionStatus.


2. I have a page in my project that has a listbox populated with the questiontext from the database. The user doubleclicks on the questiontext in listbox and is then presented with a page where they can type in their answer to the question.

3. The user types their answer into an input box - clicks on a save button - the answer is then saved as the Question's QuestionID DOT txt (12.txt for example) and the database is updated with a status of A for the answered question.

4. What I Need: An additional page where a RichText object is populated with the text of each question (pulled from the database where status = A) followed by the related text from the text file .

For Example - my end result should be a CompleteDocument.rtf file that is something like:

WHAT IS YOUR NAME? <-- pulled from Database with questionID 1
My name is john doe <-- pulled from text file (1.txt for example)

WHO IS YOUR FAVORITE AUTHOR? <-- pulled from database with questionid 2
My favorite author is Stephen King <--pulled from text file (2.txt)

WHAT IS YOUR FAVORITE COLOR?
My favorite color is Red

...

MY DILEMMA:

How do I merge the text from the questions (held in the database) and the text for each answer for the question to a RTF file that has all the questions and answers in one object like the example above?

Is there a way to merge RTF files and then open them in the richtext object in my page described in item 4 above?

If I saved the answer to an RTF file by having the user type their answer into an RTF object and saving as an RTF file (a change to item 3) would that simplify merging the files - how would I merge multiple RTF files?

I would consider using the database for the answer also but the text for the answer could be 1000's of characters and may not fit into the database field.

Can anyone help me, please? I'm at a stand still on this project until I figure out a solution to this step. If there's a better way to accomplish the same thing I'd also like to hear it.

Thanks for your assistance!!!

Sue

RizlaUK
02-03-2008, 08:11 AM
I would consider using the database for the answer also but the text for the answer could be 1000's of characters and may not fit into the database field.

that dosent matter, sqlite can handle that

i would keep everything in the database (just for tidiness and ease of use)

database table: QuestionID, QuestionText and QuestionAnswer

that way your "QuestionStatus" becomes your "QuestionAnswer" if the text in column "QuestionAnswer" == "" then the question has not been answered

as for merging the rtf output should not be to hard (do you mean like a report at the end of the questionnaire)

but, you will need to save the the text to the database as rtf text "RichText.GetText" in order to keep any formatting so it might pay you to make a 2nd helper app to build the database,


i,ll see if i can get a example to you (time permitting)

sue
02-03-2008, 08:33 AM
I definitely like the idea of keeping it all in the database but didn't think I could keep formatting - plus I thought it would be an issue with the amount of text that could possibly be used for an answer.

As far as the merging of the RTF output - that is simply for the ability to create the document with questions and answers and since I was holding the answers in separate files I needed to know how to combine all the individual files into one document. However, if the database will store formatted text as the answer (especially carriage returns between paragraphs) then I just need to know how to populate the rich text object with the items in the database and won't need to merge the individual files. Does that make sense?

I would truly appreciate an example - if your time permits.

So I guess my real needs are:

How to populate a database field with formatted text and then how to populate a RTF object with the data in the database.

Thanks for your help!! You already taught me that my doubt about the answers being able to be stored in the database is unwarranted - and I'm feeling a little more optimistic that this can work! ;D

Sue

RizlaUK
02-03-2008, 09:32 AM
well i dont know what the character limit is in a sqlite database but i have some stuff on sqlite (recipes, walkthroughs, etc) some must have 10.000+ characters, and the formatting should not be a problem as RTF formatting is just more text chars decoded by the rtf object (or word pad) just like a web browser dose with html,

anyway, i'll get on to that example

sue
02-03-2008, 10:06 AM
Thanks RizlaUK!

I'm looking forward to learning more about the RichText Object and how to work with it and SQLlite and AMS.

Sue

sue
02-04-2008, 10:24 AM
I've got the rich text box displaying the items from the database working - attached is an example - if anyone needs something similar.

I haven't looked at the RTF formatting when data is added and retrieved from the database yet.

Sue

RizlaUK
02-04-2008, 11:30 AM
sorry sue, i still havent had time to make that example, but it looks like you are half way there anyway :yes

Loes
02-04-2008, 11:37 AM
I've got the rich text box displaying the items from the database working - attached is an example - if anyone needs something similar.

I haven't looked at the RTF formatting when data is added and retrieved from the database yet.

Sue

Hi Sue,

One of the members of this forum TJ_Tigger has a lot of video tutorials about databases and AMS on his website: see http://www.tj-tigger.com/pub/TiggTV/TiggTV.html

Hope this helps,
Loes

sue
02-04-2008, 11:39 AM
Thanks, RizlaUK, I understand. I'm making progress, albeit a little slow, it's still progress! ;D

Dermot was very kind to share a rich text object example with bold, italic, etc. in a post the other day (Thanks, Dermot).

But, if anyone has an example that includes font face and font size formatting I would love to see it !! Then I want to test posting and retrieving from database with font sizes and faces changes.



Sue

sue
02-04-2008, 11:50 AM
Thanks, Loes,

I have acceptable database skills - my issues are more with the Rich Text object that's new in version 7.0 and interacting with it for formatting and databases.

You're right, though, I've watched all of Tigger's video tutorials and I would recommend them to everyone!!

Sue

Dermot
02-04-2008, 02:50 PM
Hi Sue

That example I sent you does let you choose the font face and size.

sue
02-04-2008, 03:04 PM
Hmmmm, Dermot ....I'm not seeing it....

sue
02-04-2008, 03:08 PM
I found it ..... I copied your stuff into a project I am doing and somehow missed that icon in the copy..... duh!!!

Thanks for making me loook again!

Sue

:D