i looked at the help file and it says:
Concatenates two AnsiStrings.
friend AsiString __fastcall operator +(const char* lhs, const AnsiString&
rhs);
Returns an AnsiString that is the concatenation of strings lhs and rhs.
AnsiString __fastcall operator +(const AnsiString& rhs) const;
Returns an AnsiString that is the concatenation of this AnsiString and rhs.
Can someone help me interpret how to do this? (ie just give me and example
how to do this)
it sounds silly, but i cant seem to figure it out =<
Thanks,
Michael
AnsiString aString = AnsiString("This ") + " and that";
AnsiString aString = AnsiString(" This ") + " and that";
(The conversion of char * to AnsiString is the problem)
AnsiString File1 = "text";
int i ;
for (i=0;i<10;i++)
File1 += IntToStr(i) + ".trf";
Presently, at the end of it, I still have text in File1, instead of
text0.trf, etc. Any suggestions on what I am doing wrong, or how to add an
integer to a string?
thanks,
--
Vijay
______________________
Vijay Gopal Kovvali
301 Ball Street #2087
College Station, TX 77840
Home: (409) 862-9288
Office: (409) 845-9892
Liz Albin <Elizabe...@bowne.com> wrote in message
news:7l089e$fg...@forums.borland.com...
Vijay wrote:
Hi,
i don't understand what you mean, the snippet runs as it should, assigning
File1=="text0.trf1.trf2.trf ecc. ecc. ecc.".
Regards
Vittorio Digilio
Thanks for looking at it.
Vijay
Vik <stra...@server.inmedia.it> wrote in message
news:3773ED2F...@server.inmedia.it...
AnsiString File1 = "text";
int i ;
for (i=0;i<10;i++)
File1 += AnsiString(IntToStr(i) + ".trf");
This will produce a string like this:
"text0.trf1.trf3.trf"...
Is that what you wanted the string to be like? Or did you want strings like
"text0.trf", "text1.trf", etc..? If the latter, then your originally-posted
code is wrong for this.
Gambit
Vijay <vgk...@unix.tamu.edu> wrote in message
news:7l0ibu$ft...@forums.borland.com...
try to build all the project (from the menu), not to make it (CTRL + F9).
Alternatively you may try to re-assemble it from scratch, if it's not too big.
Maybe it helps.
Otherwise you should post the whole snippet of code where the for(...) it is.
Regards,
Vittorio Digilio
I have one edit box, one CSpinEdit and a checkbox. The edit box takes the
name of a file, the CSpinEdit takes an integer, and checkbox tells whether I
should create a CORSIM file (some software file we use). If the checkbox is
checked, I read the editbox file. This editbox file contains a list of
files. My function reads each filename contained in the editbox file, and
creates copies of this file (as many as the number given in CSpinEdit) by
adding 0,1,2, etc. Then all these copies are written to another file (.inp
file).
The place I am having problem is
TempFileName2 = TempFileName2 + IntToStr(i) + ".trf";
If TempFileName2 has "text" earlier, after this I should have "text0.trf",
etc., instead, I am getting "text". Using the debugger I can see that
TempFileName2 contains the correct text before this operation. Seeing from
your responses and my friends here, I see that there is nothing wrong with
this line of code.
Vijay
// Please note that I have copied the form variables into my own user
variables
void TRandRun::Run()
{
int i;
char filebuff[81];
AnsiString TempFileName1;
AnsiString TempFileName2;
fstream CORFile;
fstream SimFile(SimFileName.c_str());
if(CreateListFile) // if the checkbox is checked
{
TempFileName1 = SimFileName; // SimFileName is the name in the editbox
i = TempFileName1.Pos(".");
TempFileName1.Delete(i+1,3);
CORListFileName = TempFileName1 + "inp";
CORFile.open(CORListFileName.c_str());
CreateListFile = false; file://So that the loop doesn't execute again
} // All this to create the inp file for CORSIM Input File
SimFile.getline(filebuff, sizeof(filebuff));
istrstream ReadInto(filebuff,strlen(filebuff));
// ReadInto is the stringstream
ReadInto>>TempFileName1.c_str();
TempFileName2 = TempFileName1;
i = TempFileName2.Pos(".");
TempFileName2.Delete(i,4);
for(i=0;i<NoOfSimFiles;i++){
// sprintf(TempFileName1.c_str(), "%s%d.trf", TempFileName2.c_str(),i);
// I tried sprintf also without success
TempFileName2 = TempFileName2 + IntToStr(i) + ".trf";
CopyFile(TempFileName1.c_str(), TempFileName2.c_str(),false);
CORFile<<TempFileName2.c_str()<<endl;
TempFileName2 = AnsiString(TempFileName2 + IntToStr(i) +
AnsiString(".trf"));
Gambit
Vijay <vgk...@unix.tamu.edu> wrote in message
news:7l3gdg$ik...@forums.borland.com...