| View previous topic :: View next topic |
| Author |
Message |
Gary Guest
|
Posted: Sun Jan 04, 2004 5:45 pm Post subject: AnsiString and TString |
|
|
Why on earth do we have two classes of Strings? Previously we had none, now
we have two! And two is one to many.
Translation: I'm getting a Cannot convert TString to AnsiString error
message and its really annoying because what I want to do appears to be not
possible because we have two different String classes.
I'm trying to send RichEdit1->Lines to an external Pascal function. So I
declare my external Pascal header with AnsiString. Get that message about
converting TStrings to AnsiString. So I changed the declaration of the
Pascal function to TStrings and get errors that TStrings cannot be made or
something like that.
|
|
| Back to top |
|
 |
Peter Agricola Guest
|
Posted: Sun Jan 04, 2004 7:25 pm Post subject: Re: AnsiString and TString |
|
|
"Gary" <nospam (AT) nospam (DOT) net> wrote:
| Quote: | Why on earth do we have two classes of Strings?
|
We don't. We have much more ;-)
| Quote: | I'm trying to send RichEdit1->Lines to an external Pascal function. So I
declare my external Pascal header with AnsiString. Get that message about
converting TStrings to AnsiString. So I changed the declaration of the
Pascal function to TStrings and get errors that TStrings cannot be made or
something like that.
|
Lines is of type TStrings wich is a list of strings. For passing the
(unformatted) text as an AnsiString use the Text property of richedit.
Peter
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sun Jan 04, 2004 10:08 pm Post subject: Re: AnsiString and TString |
|
|
"Gary" <nospam (AT) nospam (DOT) net> wrote
| Quote: | Why on earth do we have two classes of Strings?
|
We don't. TStrings is not a string class. It is a container of multiple
string values. That is not the same thing.
| Quote: | Translation: I'm getting a Cannot convert TString to
AnsiString error message
|
Please show your actual code.
If you are trying to assign an AnsiString to a TStrings, you need to use the
TStrings' Text or CommaText property, depending on your actual needs.
| Quote: | I'm trying to send RichEdit1->Lines to an external Pascal function.
|
Use the Text property then:
RichEdit1->Lines->Text
| Quote: | So I declare my external Pascal header with AnsiString. Get that
message about converting TStrings to AnsiString. So I changed
the declaration of the Pascal function to TStrings and get errors
that TStrings cannot be made or something like that.
|
TStrings is an abstract base class, meaning it has pure virtual methods in
it. TStrings cannot be instantiated directly. To instantiate an instance
of it, you need to instantiate a descendant class instead, such as
TStringList.
Gambit
|
|
| Back to top |
|
 |
Gary Guest
|
Posted: Mon Jan 05, 2004 12:17 am Post subject: Re: AnsiString and TString |
|
|
Thanks guys! I was ranting and actually got answered. Thanks :)
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote
| Quote: |
"Gary" <nospam (AT) nospam (DOT) net> wrote in message
news:3ff85157 (AT) newsgroups (DOT) borland.com...
Why on earth do we have two classes of Strings?
We don't. TStrings is not a string class. It is a container of multiple
string values. That is not the same thing.
Translation: I'm getting a Cannot convert TString to
AnsiString error message
Please show your actual code.
If you are trying to assign an AnsiString to a TStrings, you need to use
the
TStrings' Text or CommaText property, depending on your actual needs.
I'm trying to send RichEdit1->Lines to an external Pascal function.
Use the Text property then:
RichEdit1->Lines->Text
So I declare my external Pascal header with AnsiString. Get that
message about converting TStrings to AnsiString. So I changed
the declaration of the Pascal function to TStrings and get errors
that TStrings cannot be made or something like that.
TStrings is an abstract base class, meaning it has pure virtual methods in
it. TStrings cannot be instantiated directly. To instantiate an
instance
of it, you need to instantiate a descendant class instead, such as
TStringList.
Gambit
|
|
|
| Back to top |
|
 |
Gary Guest
|
Posted: Mon Jan 05, 2004 2:09 am Post subject: New problem |
|
|
I guess I don't remember how to call a Pascal function after all. I get an
unresolved external '__Stdcall RtfToHtml(System::AnsiString) referenced....
I tried this it in my h file and my cpp file but either way I declared it as
such:
extern pascal AnsiString RtfToHtml(AnsiString textstuff);
my code looks like this where I call it. It's been changed trying to get
around errors. Previously Memo1->Lines->Text replaced HTMLString. And
HTMLString is of type AnsiString.
HTMLString = RtfToHtml(RichEdit1->Lines->Text);
Memo1->Lines->Text = HTMLString;
Memo1->Lines->SaveToFile(FileName);
I added Rtf2Html.pas to my project.
I've never tried to call a Pascal function from c before. I was taught how
around 94 or 95 so it's been a while. Does it show? ;)
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Jan 05, 2004 2:58 am Post subject: Re: New problem |
|
|
"Gary" <nospam (AT) nospam (DOT) net> wrote
| Quote: | I guess I don't remember how to call a Pascal function after all.
|
When you say "Pascal", are you referring to a function that is actually
written in the Delphi Pascal language? Or just a C++ function that uses the
__pascal calling convention? They are very different things. You need to
clearify exactly what you are trying to accomplish.
Gambit
P.S. when you start discussing a new topic, you should start a new thread
for it.
|
|
| Back to top |
|
 |
Gary Guest
|
Posted: Mon Jan 05, 2004 4:26 am Post subject: Re: New problem |
|
|
It's written in actual Pascal. Somewhere on the ngs, someone was pointed to
this function when they wanted HTML from a RichEdit and I downloaded it too
because I wanted to have HTML from a RichEdit as well.
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote
| Quote: |
"Gary" <nospam (AT) nospam (DOT) net> wrote in message
news:3ff8c770 (AT) newsgroups (DOT) borland.com...
I guess I don't remember how to call a Pascal function after all.
When you say "Pascal", are you referring to a function that is actually
written in the Delphi Pascal language? Or just a C++ function that uses
the
__pascal calling convention? They are very different things. You need to
clearify exactly what you are trying to accomplish.
Gambit
P.S. when you start discussing a new topic, you should start a new thread
for it.
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Jan 05, 2004 4:50 am Post subject: Re: New problem |
|
|
"Gary" <nospam (AT) nospam (DOT) net> wrote
| Quote: | It's written in actual Pascal.
|
I assume that the Pascal is being added to the C++ project directly,
correct? If so, then simply put the code into its own .PAS unit (if it is
not already) and add that unit to the project. The IDE will automatically
produce an .HPP header file for your C++ code to use to access the Pascal
functions/classes/varaibles.
Gambit
|
|
| Back to top |
|
 |
Andrea Guest
|
Posted: Tue Jan 06, 2004 5:57 pm Post subject: Re: AnsiString and TString |
|
|
You can use
RichEdit1->Lines->Add( ... )
to add an AnsiString to a RichEdit component.
Hope this help,
Andrea Peri.
On Sun, 4 Jan 2004 12:45:56 -0500, "Gary" <nospam (AT) nospam (DOT) net> wrote:
| Quote: | Why on earth do we have two classes of Strings? Previously we had none, now
we have two! And two is one to many.
Translation: I'm getting a Cannot convert TString to AnsiString error
message and its really annoying because what I want to do appears to be not
possible because we have two different String classes.
I'm trying to send RichEdit1->Lines to an external Pascal function. So I
declare my external Pascal header with AnsiString. Get that message about
converting TStrings to AnsiString. So I changed the declaration of the
Pascal function to TStrings and get errors that TStrings cannot be made or
something like that.
|
|
|
| Back to top |
|
 |
|