Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / Another RichEdit Problem

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Another RichEdit Problem
#764
Posted by: 2003-02-01 07:38:12
As I understand RichEdits, they are able to display formatted text--such as multiple fonts, styles etc--as one might find in a Rich Text Format file. My problem is that I want to display a single line of text from a rtf file in a RichEdit box and I want the file to display as it does in Word.

I can't seem to get it to work. I have played around with the PlainText property of the RichEdits to no avail. Both True and False yeild the same results: Formatting symbols but not the expected text.

What follows is a sub for display of a line of RTF Formatted text.

SUB DisplayApparatus
 
DIM ApparatusStream AS QFILESTREAM
DIM Apparatus AS STRING
Apparatus = "Apparatus.rtf"

' Brings us to the base folder
Dir = "C:RQTEXTVAR"

' Test for existence of file Apparatus.rtf
    IF ApparatusStream.Open(Dir + BooksBox.Text + "" + ChaptersBox.Text + Apparatus, 0) = False THEN

' Give error message if not found   
        MESSAGEDLG("Error opening Apparatus in DisplayApparatus", dtError, dbOK, 0)
       
    ELSE

' Iterating through the file a line at a time   
        WHILE ApparatusStream.Position < ApparatusStream.Size
       
            A$ = ApparatusStream.ReadLine

' The Leftmost 2 characters are to locate the proper line
' This is selected in the QCOMBOBOX "VersesBox"       
            IF VAL(LEFT$(A$, 2)) <> VAL(VersesBox.Text) THEN

' If no match, read another line           
                WEND
               
            END IF

' Clear RichEdit before displaying selected line           
        ApparatusDisplay.Clear

' Display the selected line minus the leftmost three characters.
' Two characters are the verse number, the third is a space       
        ApparatusDisplay.AddStrings RIGHT$(A$, LEN(A$) - 3)
   
    END IF
   
END SUB
Message2. Re: Another RichEdit Problem
#765
Posted by: 2003-02-01 07:48:50
Well, I found a logical error in my code that ended the while...wend loop immediately if a match was not found. I fixed this in my program but the problem still exists. No formatted text. Can someone tell me what I'm doing wrong (or, conversely, what I'm not doing right)?

Thanks
Message3. Where's your format code?
#766
Posted by: guidance 2003-02-01 09:56:46
Yes, besides your WEND problem, I didn't find your font setting code? You should use SelAttributes, see doc (http://h.ods.org/_scripts/file.php?f=492&r=2330#2468) and example:
http://h.ods.org/_scripts/file.php?f=1861&r=2330
Message4. Re: Where's your format code?
#767
Posted by: 2003-02-01 12:06:30
The Format codes are in the files. They are .RTF files; I simply want to display the formatted text. Is there no way to do this?

The Example was interesting but too complex for me to get much out of or to extract what is really relevant to my needs.

Craig
Message5. SelAttributes
#768
Posted by: guidance 2003-02-01 13:33:23
I said please note SelAttributes statement at the end of the example code.
QFileStream.ReadLine doesn't recognize RTF, the "line" it read is a plain text line, this line may include formatting information, but is not equivalent with its RTF line. I'm afraid RTF file is binary, not plain text, you can check it with an HEX editor.
I don't know the RTF format syntax actually, sorry.
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥738.00 ·
 
 
¥1,480.00 ·
 
 
¥397.00 ·
 
 
¥950.00 ·
 
 
¥264.00 ·
 
 
¥1,005.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0