Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

readfromrtffile

Status
Not open for further replies.

JBirdieH

Technical User
May 22, 2001
37
US
I am trying to read from a .txt file that has been created as an ascii fixed in pdox. I need to clip it in to another application. The readfromfile works fine, but the "fixed" aspect is lost and the data is messy. The readfromrtffile gives me the error "cannot read from file". what is going on? Is the file busy? I can't figure out how to get a more explicit error-or how to get get readfromrtffile to work. Thanks.
 
JBirdieH,

Which version of Paradox are you using and which application are you pasting the data into? I've tried the following code and it seems to retain the formatting fine:

Code:
var
   m Memo
endVar

   m.readFromFile( "customer.txt" )
   m.writeToClipboard()

Now, I have seen cases where certain applications, such as MS Word, try to help by pre-processing text pasted in from the Clipboard. This may be why you're losing the formatting.

If this seems possible, look for an Edit | Paste Special command that lets you choose the way the text is pasted from the CLipboard or see if there's an alternate way to read the data in. For example, MS Word lets you insert text files without any additional processing.

As far as the error you get from trying readFromRTFFile() on your fixed text file goes, it's what I like to call an "honest" error. That is, it's literally the truth, though certainly not terribly well worded.

While RTF files are plain text files, they contain formatting instructions, similar to HTML markup. When Paradox tries to import an RTF file, it expects a certain amount of this markup to be present in the target file. In this case, there is no RTF markup, so Paradox cannot properly interpret its contents. Hence, the error.

Now, we might argue if the error is specific enough, perhaps by wishing that Corel would add an additional error to the stack in that situation (e.g. a message like "File does not appear to be an RTF file."), but that's not necessarily productive. :)

In any event, readFromFile() is the method you want to use for this.

Now, if you need to process the file, you might consider using TextStream methods to read it into a String variable. When you've finished, you can copy the String value to the Clipboard using something along these lines:

Code:
var
   s  String
   m  Memo
endVar

   s = importTextFile()  ; proc that imports the file
   m = Memo( s )
   m.WriteToClipboard()

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top