Guidance Forums / Rapid-Q Basic / Saving files?

Search 搜索
Home Home

Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Saving files?
Posted by: Nova_Shard 2004-09-20 12:51:09
Hello gang,

   Hopefully, this should be a pretty easy question.  I'm working on a text-editor program, and I've reached the point of giving functionality to the various drop-down menus.  Right now, I'm stuck on the save file feature.  What I need is a way for the user to be prompted to save the contents of a Qrichedit box in a file of their choosing.  I need them to be able to create the name of the file, as well as assign the type of file it's going to be...(*.txt, *.rtf).

   The command richedit.SaveToFile("example.txt") only seems to allow the saving to a specific, predetermined file and type.  And I've discovered the QSaveDialog area of the documentation, but it's description is extremely sparse.  How do I use this thing to save the contents of my Qrichedit box?
Message2. Re: Saving files?
Posted by: 2004-09-21 10:20:43
I use a buffered method of loading and saving; an invisible RichEdit. The big advantage is that it can be used to restore (undo changes) by simply re-copying its contents when needed.

So step 1 is defining that RichEdit;

    DIM RiEd as QRichEdit
    RiEd.plaintext = 1
    RiEd.visible = 0
    RiEd.Parent = Form

I only use .txt files actually. I use a string to pass the name and location of the file to be loaded to the bit of the program that does the actual loading and / or saving; this is step 2.

    drvnm$ = "C"
    drctrnm$ = "MyStuff"
    flnm$ = "example"
    f$ = drvnm$ + ":\" + drctrnm$ + "\" + flnm$ + ".txt"

Step 3 is loading the thing;

    plup$ = RiEd.Text

or step 3 be saving the thing of course;


Message3. Re: Saving files?
Posted by: Nova_Shard 2004-09-21 22:45:00
   Thanks for the help, baardaap.  It's appreciated.
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
© Sat 2018-6-23  Guidance Laboratory Inc. Hits:0