Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

Put contents of a dat file into an editbox??

How do I take the contents of edit1.dat and put it in Edit1??  In case you are wondering this is the opposite of the question (that someone just answered) about saving the input to a dat file...
0
4099aol
Asked:
4099aol
  • 6
  • 6
1 Solution
 
q2guoCommented:
AnsiString S("edit1.txt");
FMyFile = new TFileStream(S, fmOpenRead);
S.SetLength(FMyFile->Size + 1);
FMyFile->Read(S.c_str(), FMyFile->Size);
S[FMyFile->Size] = `\0';

Edit1->Text = S;
0
 
4099aolAuthor Commented:
Error messages..

[C++ Error] Options.cpp(284): Undefined symbol'FMyFile'
[C++ Error] Options.cpp(287): Illegal character '`'(0x60).


0
 
q2guoCommented:
Sorry line

FMyFile = new TFileStream(S, fmOpenRead);

should read

TFileStream FMyFile = new TFileStream(S, fmOpenRead);
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
4099aolAuthor Commented:
[C++ Error] Options.cpp(286): Cannot convert 'Classes::TFileStream *'to 'Classes::TFileStream'.

[C++ Error] Options.cpp(287):Pointer to structure required on left side of -> or 0>*.
0
 
q2guoCommented:
Sorry again, add the * before FMyFile

TFileStream *FMyFile = new TFileStream(S, fmOpenRead);
0
 
4099aolAuthor Commented:
No problem,  but still more errors.

[C++ Error] Options.cpp(289): Illegal character '`' (0x60).
[C++ Error] Options.cpp(289): Illegal character '\' (0x6c).

thanks
0
 
q2guoCommented:
Line

S[FMyFile->Size] = `\0';

is suppose to be

S[FMyFile->Size] = '\0';


Do you see the difference?
the character before \ is suppose to be ' not `
0
 
4099aolAuthor Commented:
thanks, now.  Can you quickly change it a little bit??  I need to change Edit2 also (smae way), but I am not sure what variabels to change.
0
 
q2guoCommented:
What do you want to change Edit2 to?
0
 
4099aolAuthor Commented:
Will edit1 hold the registration code and edit2 holds the username.  So when the user opens up this dialog box I want it to tell them who the program is currently registered to (user/Edit2) and what the registration code is (Edit1).


0
 
q2guoCommented:
Assume the user name is stored in edit2.txt

AnsiString S2("edit2.txt");
FMyFile2 = new TFileStream(S2, fmOpenRead); S2.SetLength(2FMyFile->Size + 1);
FMyFile2->Read(S2.c_str(), FMyFile2->Size);
S2[FMyFile2->Size] = `\0';
Edit2->Text = S2;
FMyFile2->Free;   // to free resource related to the filestream
0
 
4099aolAuthor Commented:
thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now