see variable value in the emulator

Login to reply to this topic.
Wed, 2008-03-26 16:30
Joined: 2007-11-21
Forum posts: 14

Hello
How can I see the value of a variable in the emulator? I'm using Symbian c++ s60 3rd FP1. thanks


Wed, 2008-03-26 16:49
Forum Nokia Champion
Joined: 2006-10-12
Forum posts: 424
Re: see variable value in the emulator

Debug on emulator and check the variables view in the debug mode

Wed, 2008-03-26 16:53
Joined: 2007-11-21
Forum posts: 14
Re: see variable value in the emulator

ok, but if I want to view in the screen of a mobile phone the value of a variable? is it possible?

Wed, 2008-03-26 17:14
Forum Nokia Champion
Joined: 2006-10-12
Forum posts: 424
Re: see variable value in the emulator

Well..most of such things are possible Smiling
I really dont know what exactly you are trying to achieve. If you want to just see some value for the kicks of it, Check how helloworld is displayed in helloworld Application Eye-wink

If you want to draw some elaborate, maybe something like textbox..labels, etc..I guess you should check the SDK docs which gives you how to do that. Also check articles on this website and Forum Nokia and Wiki there. There are number of examples and codes and articles.

If you have any much more specific need, you really need to put in some efforts to explain.

Wed, 2008-03-26 17:20
Joined: 2007-11-21
Forum posts: 14
Re: see variable value in the emulator

Thanks, I only want to see the value of a variable in the screen to check that it's correct. I've read the helloworld example and I've only seen how to see constant or labels (such as hello world!) but i don't know how to see in the screen "4" if the variable value is 4 (ex=4;). Anyway I'll read the sdk docs. Smiling

Thu, 2008-03-27 05:24
Joined: 2007-09-15
Forum posts: 57
Re: see variable value in the emulator

You can display any value, constant or variable. Use "CAknInformationNote" and put the value you want to display in the TBuf, and pass it while calling ExecuteLD on the note.

Good luck.

Thu, 2008-03-27 08:58
Joined: 2006-04-19
Forum posts: 113
Re: see variable value in the emulator

Hi,

For this you can simplay use alertWin or Infomsg();

eg

TInt val;
TBuf<25> testBuf;
testBuf.Num(val);
CEikonEnv::Static()->AlertWin(_L("Check Val"),testBuf);


"To the question of your life , you are the only Answer. To the problems of your life,you are the only Solution".

Thu, 2008-03-27 09:55
Joined: 2007-11-21
Forum posts: 14
Re: see variable value in the emulator

Thank you very much!
Smiling

Thu, 2008-03-27 10:54
Joined: 2007-11-21
Forum posts: 14
Re: see variable value in the emulator

Hi again!
I've got a problem. this line works perfectly the first time it is read in a loop but when the value of the variable changes there is an error: Application closed KERN EXEC 3. how can i solve this?

Thu, 2008-03-27 10:59
Forum Nokia Champion
Joined: 2006-10-12
Forum posts: 424
Re: see variable value in the emulator

Reason for Kern Exec-3 from document:

This panic is raised when an unhandled exception occurs. Exceptions have many causes, but the most common are access violations caused, for example, by dereferencing NULL. Among other possible causes are: general protection faults, executing an invalid instruction, alignment checks, etc.

Obviously in a loop that is going to create problem..Paste your code here

Thu, 2008-03-27 11:23
Joined: 2007-11-21
Forum posts: 14
Re: see variable value in the emulator

these are the instructions that are in the loop. The first time the value is ok but the second time i've got the same value printed (it doesn't change) and then the kern exec 3 error appears.

int hr=0;
hr=HeartRate(); //this variable changes its value everytime it loops
TBuf<20> testBuf;
testBuf.Num(hr);
CEikonEnv::Static()->AlertWin(_L("HR:"),testBuf);

thanks

Fri, 2008-03-28 06:29
Joined: 2007-09-15
Forum posts: 57
Re: see variable value in the emulator

For logging this sort of data, I usually make use of files. Just make a file and in every loop of your function, append the value to the end of the file.
Or
On a debugger, put the breakpoint and check the value of "hr" on every iteration.

For using files use the RFs and RFile APIs.

Fri, 2008-03-28 09:27
Joined: 2007-11-21
Forum posts: 14
Re: see variable value in the emulator

Thanks SymbianReady, I already knew this solution but I have to display the value in the screen. Sad

Fri, 2008-03-28 10:37
Joined: 2007-11-21
Forum posts: 14
Re: see variable value in the emulator

Hi! I've tried with this code to display the variable hr:
HBufC* textResource = StringLoader::LoadLC( hr );
CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
note->ExecuteLD( *textResource );
CleanupStack::PopAndDestroy( textResource );
and I don't get the kern exec 3 error but the correct value is not displayed. a weird string is displayed. what do i have to change? thanks!

Fri, 2008-03-28 10:53
Joined: 2006-04-19
Forum posts: 113
Re: see variable value in the emulator

Hi,

I think you should put a breakpoint in your function HeartRate(); and if you are caling another function from here then put break point there also. And check the value of the required variable . this is the only way that you can get a solution as I always follow this and find the solution mostly. Try to debug it .

Regards,
Isha


"To the question of your life , you are the only Answer. To the problems of your life,you are the only Solution".

Fri, 2008-03-28 12:46
Joined: 2007-09-15
Forum posts: 57
Re: see variable value in the emulator

I had once used CAknWaitDialog and implemented the automatic updation of the text displayed as in the progress bar. Try that. It might require more effort but, this is the solution that will suit your requirement. If this is not very important and doesn't worth much effort then better go for the breakpoint debugging solution.

  • Login to reply to this topic.