Solved

Put contents of a dat file into an editbox??

Posted on 1998-02-15
12
195 Views
Last Modified: 2010-04-10
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
Comment
Question by:4099aol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 3

Accepted Solution

by:
q2guo earned 10 total points
ID: 1182259
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
 

Author Comment

by:4099aol
ID: 1182260
Error messages..

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


0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182261
Sorry line

FMyFile = new TFileStream(S, fmOpenRead);

should read

TFileStream FMyFile = new TFileStream(S, fmOpenRead);
0
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!

 

Author Comment

by:4099aol
ID: 1182262
[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
 
LVL 3

Expert Comment

by:q2guo
ID: 1182263
Sorry again, add the * before FMyFile

TFileStream *FMyFile = new TFileStream(S, fmOpenRead);
0
 

Author Comment

by:4099aol
ID: 1182264
No problem,  but still more errors.

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

thanks
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182265
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
 

Author Comment

by:4099aol
ID: 1182266
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
 
LVL 3

Expert Comment

by:q2guo
ID: 1182267
What do you want to change Edit2 to?
0
 

Author Comment

by:4099aol
ID: 1182268
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
 
LVL 3

Expert Comment

by:q2guo
ID: 1182269
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
 

Author Comment

by:4099aol
ID: 1182270
thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AVI wait icons for CAnimateCtrl in Visual Studio 2008 MFC 1 161
Printing the elements of a set declared inside a map in C++. 3 59
max float value 3 59
boost::uuid crashes 17 41
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question