|
|
User login
Feeds |
error....
|
|||||
| Mon, 2003-10-13 02:38 | |
|
I face system error when I try to run my program.....
Below is my code.... myProgramappui.cpp ------------------------------ const TPtrC KTestFile=_L("C:\\System\\apps\\testdata\\testdata.dat"); const TUint8* KTestData=_S8("12345\n"); const TInt KTestLength=5; const TPtrC8 KTestDes(KTestData,KTestLength); void CTestdataAppUi::HandleCommandL(TInt aCommand) { switch ( aCommand ) { case EAknSoftkeyBack: case EEikCmdExit: { Exit(); break; } case EtestdataCmdAppTest: { Write(); break; } default: break; } } void CTestdataAppUi::Write() { TBuf8<KTestLength+1> buf; RFs TheFs; RFile file; User::LeaveIfError(TheFs.Connect()); User::LeaveIfError(file.Open(TheFs,KTestFile,EFileWrite)); RFile f=file; RFileWriteStream out(f); out.WriteL(KTestDes); out.CommitL(); TInt iFileSize; file.Size(iFileSize); out.Attach(file, iFileSize); out.WriteL(KTestDes); out.Close(); TheFs.Close(); } myprogramcontainer.cpp ---------------------------------- const TPtrC KTestFile=_L("C:\\System\\apps\\testdata\\testdata.dat"); void CTestdataContainer::ConstructL(const TRect& aRect) { CreateWindowL(); RFs TheFs; RFile file; TBuf8<50> buf; User::LeaveIfError(TheFs.Connect()); User::LeaveIfError(file.Open(TheFs,KTestFile,EFileRead)); RFile f=file; RFileReadStream in(f); in.ReadL(buf); in.Close(); TheFs.Close(); HBufC* buf16 = HBufC::NewLC(buf.Length()); buf16->Des().Copy(buf); iLabel = new (ELeave) CEikLabel; iLabel->SetContainerWindowL( *this ); iLabel->SetTextL(* buf16); CleanupStack::PopAndDestroy(buf16); SetRect(aRect); ActivateL(); } any one know how to solve this problem? I know there are no global variable in symbian...but anyone know how to reference variables and contansts for different classes....like I want to reference variables and contansts in appui from container class.... million thanks in advance..... ![]() |
|
Forum posts: 93
Forum posts: 723
I don't know if my comments will help you, but it may be worth reading them.
1.) You can use global strings in your program, use _LIT macro for this purpose. E.g. considering the following code
I think your problem has nothing to do with global static data, as the GCC compiler (ARMI platform) complains about this type of programming error and generates a fatal error. Thus, you cannot even build your program if you have defined global static data (in a DLL).
2.) It is not always enough to call RFile::Open, because it may happen that the file does not exist and this method will not create it. In this case (i.e. when the file does not exist), Open will return an error code and this might be the reason for your "System error" dialog.
3.) Finally, your Write method should end with a trailing L, indicating that the method can leave.
Cheers,
tOtE
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/
Forum posts: 2029
Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant