error....

Login to reply to this topic.
Mon, 2003-10-13 02:38
Joined: 2003-10-03
Forum posts: 5
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..... Smiley

Mon, 2003-10-13 09:23
Joined: 2003-08-11
Forum posts: 93
error....
try changing the const to #define statements and that might make it work but usually the problem happens when I try to compile for the machine. But i guess it is worth a try.
Mon, 2003-10-13 15:28
Forum Nokia Champion
Joined: 2003-10-01
Forum posts: 723
Just a few remarks ...
Hi,

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
Code:
_LIT( KMyStringConstant, "NewLC" );
the constant, KMyStringConstant, may be used anywhere in your program (of course, depending on the location of the definition, i.e. whether it is in a source or a header file, whether or not that particular header file has been included, etc.).
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 Cool

Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/

Mon, 2003-10-13 16:11
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2029
error....
Check this page http://www.newlc.com/article.php3?id_article=150 to get a more detailed error code...

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

  • Login to reply to this topic.