Loads and saves an .rtf file or text file into a RichEdit control.
RichEdit.LoadFile filename [, filetype]
RichEdit.SaveFile(filename[, filetype])
filename:sexp
filetype:iexp
LoadFile loads an .rtf file (default) or text file specified in filename and replaces the entire contents of the rich edit control. The optional filetype can be rtfRTF (0) or rtfText (1).
SaveFile saves the contents (as an rtf file by default) of a RichEdit control to a file filename. The optional filetype can be rtfRTF (0) or rtfText (1) to save it as a text file.
Ocx RichEdit rtf = "", 10, 10, 300, 200 : .BorderStyle = 3
rtf.SelText = String( 5, "GFA-BASIC 32 ")
rtf.SelItalic = 1
rtf.SelText = String( 5, "GFA-BASIC 32 ")
rtf.SelBold = 1
rtf.SelText = String( 5, "GFA-BASIC 32 ")
rtf.SelItalic = 0
rtf.SelText = String( 5, "GFA-BASIC 32 ")
Ocx RichEdit rtf_copy = "", 320, 10, 300, 200 : .BorderStyle = 3
Ocx Command cmd = "Save RichEdit object", 50, 220, 200, 22
Do : Sleep : Until Me Is Nothing
Sub cmd_Click
Static opt|, f$
Inc opt|
Switch opt|
Case 1
Ocx CommDlg cd
cd.ShowSave
f$ = cd.FileName
rtf.SaveFile f$, rtfRTF
cmd.Caption = "Load into second RichEdit object"
Case 2
rtf_copy.LoadFile f$
cmd.Caption = "Close window"
Case 3
Kill f$
Me.Close
EndSwitch
EndSub
You can also use Input and the TextRTF and SelRTF properties to read .rtf files. For example:
Open "mytext.rtf" For Input As #1
rft1.TextRTF = Input$(LOF(1), 1)
Close #1
{Created by Sjouke Hamstra; Last updated: 12/10/2014 by James Gaite}