Need programming advice on creating an S60 algebra application

bluechord
bluechord used Ask the Experts™
on
I am a newbie started learning S60 a few weeks ago, and now I need to build a very simple "algebra test" application by modifying the "helloworldbasic" application that comes with N97 SDK.

I'm not asking for someone to build the whole application for me - I just need some guides since I got stuck. My objective is to display a dialog showing a random statement (e.g. 2+4=?) containing two 1-digit numbers, ask for user input, then display on screen whether the answer is right or wrong.

I have read some Nokia API documents e.g. S60 application framework handbook etc., and I have figured out how to display a dialog and ask for numeric input. My problems are:

- How to generate random numbers to be displayed in the dialog? I know to use Math::Random() % 10 to make random 1-digit numbers, but I couldn't figure out a way to put the numbers into a string and display it on the dialog.

- Where should I put the declarations of the strings and numbers? The .rss, .rls, or in the HandleCommandL function in UI file?

- How can I display a string on the screen after user clicks "OK"? Where should I put the string, and which function should I call to display it on screen?

- Can someone help me by explaining how the resource files and the UI file (***appui.cpp) work together? I really don't understand how the variables defined in them are accessed by each other (I have been a Java programmer for many years, but this is totally new to me)

Any help on the points I mentioned is appreciated. Please note that this is supposed to be a very simple application, so make it simple :)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
to start with, visit developer.symbian.org or forum.nokia.com for heaps of info on Symbian and S60 development. these sites have dev forums too

re. your immediate questions:

- numbers to string and so forth: http://developer.symbian.org/wiki/index.php/Descriptors_Cookbook (yes, that's me ;) )
then on the dialog you definitely have some controls like labels or editboxes, so display it there; or perhaps the easiest way is to use some message notes - you can add it in UI designer for instance

- declarations: depending on the architecture, you have App, Document, AppUI and some View classes by default, so you can put all declarations according to the logic of your app - it's not much different from Java after all; all declarations will be in *.h files if you want them to be class members, or in *.cpp as global variables, or inside some function as local variables

- look in samples, helloworld definitely displays something on the screen, so you can do the same; now, when you click some menu or softkey, it is usually routed to some HandleCommand() function at the View level - so you can handle it there

- ***appui class is usually working like an engine, so you have your resources for views/forms/dialogs - the UI in other words -  and AppUI class creates those views/forms and manages them

I should admit that above answers may be unclear :), but with Symbian development it usually takes some time to get into it, and sometimes quite a long time. Why can't you just use J2ME if you have long Java history?

Author

Commented:
Thank you alexey, I'll read your cookbook and give it a shot firstly :)
I wish I could use J2ME too..but I have to do some Symbian C++ this time.
you could use Carbide.c++ and its UI designers, it makes it a bit easier.

Author

Commented:
I'm now totally confused..
In helloworldbasic, all strings are defined in "helloworldbasic_01.rls" file, and I guess it's for localisation? The declaration is in form  -- rls_string *** "hellow world" --

Since now I want to generate two TInt numbers, where should I declare them? I need these two values for the string to be displayed as the label of query dialog, so they need to be accessed at the .rss file.
And you told me to declare them in .cpp file to make them global, but I looked into all cpp files and couldn't find a place to put the declarations..

Also, in the HandleCommandL() function in **appui.cpp, I need to compare the user input to the "correct answer". So the numbers also need to be accessed there.

Anyway, I'm just confused because I didn't find any declaration statements anywhere except in the .rls file, and I couldn't declare TInt variables in there.
yes, rls is for localisation, you could have resource files for diff languages

so you can declare TInt etc class members in eg AppUI header file and use them in cpp.

I'd advise you to have a look at other samples where you'll find all such declarations and examples of usage

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial