PDA

View Full Version : [SCRIPT] Advanced RPN calculator



nuukiaworld
15-10-2005, 08:38 PM
I liked very much Yak's Advanced calculator, but it missed two very important functions: inverse and memory. First I decied to add these to it by myself but then I realized that I am able to write a really advanced calculator, a calculator that uses Reverse Polish Notation :grin: . (As you can guess, I am a great fan of Hewlett Packard's Reverse Polish Logic calculators!)

Even this first version uses dynamic memory for the stack, and the stack is preserved even if the application is closed. The functionality of almost 40 commands of HP calculators are available (see the .nrx file for complete instructions).

I have still two problems, I hope that somebody may give some advice:

How should cleanly close the options menu so that my own actions are reactivated after pressing Back in the option menu? :-? <solved>
How I can open a (static) menu so that the user can use numeric shortcuts (like in the phone main menu)? Has anybody reversed that functionality? :-? <solved>

If you have any other comments or tips on this application, please share also them on this thread!

Download the version 1.50 of rpn_calculator from this url:
www.panuworld.net/nuukiaworld/download/nokix/ (http://www.panuworld.net/nuukiaworld/download/nokix/)

nEMO
16-10-2005, 11:43 AM
wow :-o Nice !!

yak
16-10-2005, 05:47 PM
first of all... are your from the legendary NUUKIAWORLD site? i made my first f/mbus cabe using instructions from this site.

then i huge thank you for new script.

and about the programming stuff, if you've used set_action() to set your own navi keys action it will be reseted after the menu is closed. the phone doesn't remember this when menu is opened, it will fall back to dispatcher's (5e0 func.) action. if you're using only one action it is best to set it as dispatcher's default by giving it as arg to add_5e0_id.rx script. if you use multiple actions, you have to react on menu closing message (0x388) and set your action back.

about the second thing, i haven't done anything like this yet so i'm not sure but i think it is controlled by some flag in menu's dispmode field (maybe 0x10?). i'll try to check this and give some more info.

cheers
yak

nuukiaworld
18-10-2005, 07:28 AM
You already guessed who I am. It is nice to hear that NuukiaWorld has been one springboard for at least one of today's greatest DCT-3 masters...

I tested the dispmode 0x10 flag. It seem not to be a "main menu formatting" flag (as named in the Nokix includes) but a "enable menu shortcuts" flag instead. You can combine it with 0xC0 to create a list-formatted menu with shortcuts enabled. So in the next release of my RPN calculator the user may choose the calculation commands quickly by using numeric menu shortcuts! :-)

Detecting the user leaving the menu is not possible with MSG_CLOSE_MENU, as it is not sent when the Back is pressed in the top-most level (of the my own options menu). I used the _debug_dispatchers.nrx to see the messages, and the only message that can be used to indicate backing from the menu is MSG_REQUEST_QUIT. But do I need to call menu_close() or is the menu already closed when the MSG_REQUEST_QUIT is received? -- The meaning of menu_close() is not clear for me -- need to test...

There seem to be some function declarations missing from the Nokix include files. Even it they don't affect the compilation, including them there would explicitly inform developers about the available functions. For example, RPN calculator uses the realloc() you have included in LOCATE.RX, however, it is not declared in any Nokix header file.

Is the set_action you mentioned a undocumented/unprototyped function too? So far I have changed the actions by using send_message(MSG_SET_ACTION...). (RPN calculator needs to change the action frequently, so the 5E0 method is not enough -- however, I will see if I split this app into may 5E0 functions some day for clarity...)

yak
18-10-2005, 01:07 PM
Yes, I have named the 0x10 flag as the "main menu formatting" long time ago but lately I saw it in some other menu and it had something with shortcuts. That's why I suggested you to test it. Now we know what it does, great!

About detecting of menu close. I was looking at Nokia's Calculator menus lately. I saw that the "Back" action of the topmost menu does not send MSG_BACK but MSG_CLOSE_MENU instead. I've included "action_select_back_close" in LOCATE.rx so you can easily set it in your menus. The submenus in the Calculator are using the MSG_BACK normally.

realloc() is a standard ANSI-C function and is defined in standard headers. It's just not everybody knows NokiX has it too. I know that now the best info source are the includes but I want to create some real developers reference some day (I just can't find time for it).

It seems that I just forgot to put set_action() to includes. I saw you've used MSG_SET_ACTION, it's ok. The only thing this message does is call of the set_action(message.argv[0]). If you want, you can do it directly too. Nokia apps always use set_action() directly. The prototype could be:
void set_action(ULONG action);

I must also say that I was impressed after looking at your sources (it's also great that you've included them). The app is very clean and I really see you feel what's going on in the phone when it runs :). It's good that you've used screen_info (did you test it on 3350 too?). Thanks to screen_info and some routines line own_get_string_width() and own_get_char_height() you can make it work correctly on any screen resolution.

And one thing more, the next snapshot will include an updated FREEGFX.rx script which supports a new draw mode: DM_BLINK, causing the graphics to automaticaly blink (like the cursor or the envelope on the main screen when SMS box is full). The usage of timers for blinking will not be needed anymore.

Hope to hear more from you.
yak

Daryl Saludares
19-10-2005, 02:47 AM
i've tested the script and it is indeed a great scientific apps in my DCT-3 phone, thanks for the effort. keep it up Sir! :-o

nuukiaworld
19-10-2005, 09:25 AM
I have updated the app to version 0.2 (download link in the first message of this thread). Now it provides possibility to use menu shortcuts for selecting the operators and functions. Note that I had to add itemflag 0x04 to all "leaf" menu functions, in addition to adding dispmode 0x10 in the root menu level. I had also to control the MSG_KEYPRESS_ASCII messages for the menu so that they are killed after the shortcut timeout is expired (otherwise they will cause app to exit). See the source for details.

I added message 0x5EE(??) to my dispatcher as it seem to be a way of detecting app exit because of long press on "Back". MSG_D_QUIT seem not to fire in that case.

This version also steals the currency functions of the built-in calculator. I included them to allow replacing the built-in calculator with this RPN one without losing any functions.

Known issues (help accepted :-P ):

The problem of "ghost" menus is still present: When visiting the menu second time, pressing back returns you back to the last menu that you should have closed already. How I could close the menu so it is cleared from "system's 5-level menu buffer"? <solved in 1.0 with new system call menu_close_all()>
Selecting angle unit using a shortcut (e.g. 8-7-1) returns the phone to the main screen. I couldn't find any message that can be used to trap this case. My dispatcher just receives MSG_D_QUIT directly without any other messages. <solved by trapping MSG_D_QUIT's with agv[0] != 3>
"Set exchange rate" seem to modify the global_buffer[] and the calculator need to be restarted after visiting the "set exchange rate" dialogs. Do anybody know what is the actual purpose of global_buffer[] in the firmware and when it is used? <solved in 0.3: "set exchange rate" seem to use the beginning of the global_buffer[] for the string to be edited>
Canceling a "set exchange rate" dialog cancels the menu also. In the built-in calculator you will return to the menu in that case. But I cannot found any reason for this difference! <solved in 1.0 with exactly same MSG_QUIT_NOW processing as in built-in calc.>
Two-digit menu shortcuts, like 10-x does not work because numeric keys are disabled after entering "10". --> MSG_DIALOG_ACCEPTED is not a realiable indication of shortcut timeout. <solved in 0.3: MSG_DIALOG_ACCEPTED means shortcut timeout only if the argv[0]=1>


I didn't find anything special in built-in calculator's root menu level actions but I noticed the MSG_MENU_CLOSE message firing when canceling the menu. I am waiting for the new locate.rx your mentioned to see if "action_select_back_close" can help in the first issue above.

I tried to include <stdlib.h> for declaring realloc(). However, some Nokix functions conflicts with ANSI C library functions so <stdlib.h> cannot be included if nokix is included. That's why I excepted to find realloc() defined in nokix includes...

screen_info is used in right-aligned printing, however, number of stack levels and their locations is currently defined in code, so the calculator is not yet completely scalabale for different display sizes.

yak
19-10-2005, 04:33 PM
MSG_D_QUIT should come no matter if you hold the C or not. it's probably some problems with MSG_NOP'ed messages or wrong action.

Try using MCM_OWN_COUNTER in confmode filed of your main options menu - this should fix problems with reopening of old menus.

If another 5E0 function will be started from yours, you get MSG_D_QUIT_NOW when it finishes and if you don't replace it with MSG_R_STAY, your app will quit immediately. This may be reason for quiting after the "exchange rate".

I named global_buffer[] so, beacause it's a global buffer used by various parts of the FW (mostly during diaogs operations). If you don't fire up any other functions from your app, you can safely use it. But you did and in such case it's better to create your own global data. The best solution would be to create a global pointer only and to alloc/free the buffer upon app init/quit.

I haven't tested the shortcuts yet so I cannot give any tips about it.

Check Calculator Options menu action fields and use _dump_actions.rx to see what messages they send. You will see that C key sends MSG_CLOSE_MENU.

I've revied all the includes yesterday and fixed them. All standard functions have beed removed and apropriate system headers are automaticaly included. So realoc() is there. I've also reworked the UI part a bit. This will be included in next snapshot.

nuukiaworld
20-10-2005, 06:47 AM
Version 0.3 is out now (link the first message). It helps in options menu and exchange rate issues, however "the ghost menus problem" are not completely resolved.

Already closed menus may reappear when backing from submenus of the options menu. <solved by removing 0x80 from dispmode of the root menu>
An invalid shortcut or selecting the angle unit with shortcut (e.g. 8-7-1) cause the phone return to the main screen. Only way to avoid this is to trap MSG_D_QUIT when menu is open and try to detect somehow what is its origin (because you don't want to trap the hangup key)? <solved by trapping MSG_D_QUIT's if argv[0] != 3>

Yes, I finally found the action that the built-in calculator is using at the main options menu. (I was looking for a "Select-Back" action but I haven't noticed that it is a "OK-Back" action.) -- Now the app uses MSG_CLOSE_MENU and sends menu_close() so the menu disappears when Back is pressed on the main level. However, the menu is not completely closed -- it may reappear. (For example, enter and cancel the main menu 3 times. On fourth time, enter a submenu: the counter shows wrong parent menu number and backing restores you to the wrong menu) :( MCM_OWN_COUNTER is already used on the main level, it does not help.

I don't agree with that MSG_D_QUIT comes always when app is closed. (Or _debug_dispatchers doesn't show it.) For example, open the exchange rate menu of the built-in calculator and keep the C pressed. The calculator dispatcher receives 0x35E and responds with 0x5EA which causes to dispatcher to be closed! If there is no response for 0x35E (like in my app), the dispatcher will receive 0x5EE and then it will be closed anyway. :-o

MSG_D_QUIT_NOW is naturally catched in my app and it closes only the menu (in case of exchange rate is set). Hmmm. Maybe it is also sent when exchange rate dialog is canceled, and I close the menu by myself... :roll:

Some of my notes on shotcuts:
DISPMODE 0x20 is present in the exchange rate submenu and it (at least) ends the shortcut processing when the submenu is entered.
DISPMODE 0x10 can be used also on submenus. In that case it will re-enable the shortcut mode even if you have not opened the submenu using a shortcut.

yak
20-10-2005, 02:00 PM
I was looking at Nokia's menu code responsible for handling invalid shortkeys and I saw that it's sending MSG_D_QUIT and normally doing so will cause the phone to return to main screen. The way out of the situation could be to check the argv[0] of the MSG_D_QUIT message. If it's caused by simple C press, it should be 0, if by a numberic key press (if you haven't NOP'ed MSG_KEYPRESS_ASCII) it should be 3, for bad shortkey and setting change (like your 8-7-1 shortcut) it is a value left from previous MSG_DISPLAY_MESSAGE message. It will differ from model to model but it will always be >3.

As for the bad menu counter at fourth menu enter. You have set the MDM_SUB flag (0x80) for your main Options menu. Put it only in submenus (if you don't specify dispmode for EZMENU.rx it will se it to 0xC0 also WITH the flag). A minute ago I saw there was same problem in Plotter and this helped. Note that in main phone menu there is no 0x80 flag too but it is in all submenus.

MCM_OWN_COUNTER has nothing to do with the problem, sorry for that. I thought so some time ago but now I checked this and I'm sure the 0x80 dispmode flag is responsible.

Well, debug_dispatchers don't show some MSG_D_QUIT, that's true (will change in next version) but this is not the case here. I've meant that MSG_D_QUIT is normally always sent. There are exceptions. You can return MSG_R_QUIT anytime and your app will quit immediately (to the main screen however). There is also something with 0x5EA message that causes the quit and the MSG_D_QUIT_NOW of course. I have made some tests with the 0x5EA and it seems that you can return it if you want your app to quit immediately (like MSG_R_QUIT mentioned above) but the phone will stay in menu. I will add it to includes as MSG_R_LEAVE.

the MSG_D_QUIT_NOW is always sent when the phone returns to your dispatcher from the one you've called. There is also a possibility to detect (through argv[0]) if the end was caused by C button.

I was lloking at the source. You're calling menu_close() in MSG_CLOSE_MENU handler, this is a bit pointless because as long as you don't replace this msg with MSG_NOP the menu_close() will be called anyway - this is what this message does after it leaves your dispatcher.

You're also NOP'ing MSG_KEYPRESS_ASCII when the menu shortcut session is finished. This way the hangup key (and numeric keys) don't cause the app to quit during the menu session. Nokia apps do that so I think it would be more elegant to NOP it only when you are on you app's main screen.

I've added dispmode 0x10 as MDM_ENABLE_SHORTCUTS and 0x20 as MDM_DISABLE_SHORTCUTS.

Thanks for your help.
yak

nuukiaworld
21-10-2005, 07:49 AM
Thank you for your help. I think that I am now able to solve all pending issues of the RPN calc app and I hope that all of us have learned something new about Nokia UI.

There is also something with 0x5EA message that causes the quit and the MSG_D_QUIT_NOW of course. I have made some tests with the 0x5EA and it seems that you can return it if you want your app to quit immediately (like MSG_R_QUIT mentioned above) but the phone will stay in menu.Yes, but what about 0x5EE? If your dispatcher don't touch it, it will be closed without any further messages (or debug does not show anything after that...)

You're also NOP'ing MSG_KEYPRESS_ASCII when the menu shortcut session is finished. This way the hangup key (and numeric keys) don't cause the app to quit during the menu session. Nokia apps do that so I think it would be more elegant to NOP it only when you are on you app's main screen.This is partly a matter of tase but in the options menu of the built-in calculator the number keys are NOP'ed, too. Maybe this is to avoid unitended closing of the calculator if you accidentally start typing a number when you are in the options menu. NOP'ing MSG_KEYPRESS_ASCII does not affect the hangup key (which should not be NOP'ed, I agree with that).

(The shortcut session detection method in 0.3 fails to detect if the shortcut mode exits because of moving the cursor with arrows... -- Something that I need to address.)

I've added dispmode ... 0x20 as MDM_DISABLE_SHORTCUTS.The meaning of 0x20 is somewhat unclear -- I have found it only in the exchange rate submenu which is normally unreachable with shortcuts. So why it is there? May be it means (also) something else?

Have a nice weekend! [Waiting eagerly for the new snapshot...]

yak
21-10-2005, 09:49 PM
Hmmm, 5EE is for example sent by the numberic keys (if you don't NOP MSG_KEYPRESS_ASCII). If you don't touch it, it will cause MSG_D_QUIT which is mostly replaced with MSG_R_QUIT by default. All this causes the quit on numeric keypresses. 0x5EE itself isn't the last message, it just causes the MSG_D_QUIT - at least when keys are pressed.

About NOPing the keypresses in menu, it's your app, do it as you like :D. It was just a suggestion.

As I said, you don't have to detect shortcut session. Just leave the MSG_KEYPRESS_ASCII alone (always) and prevent the quit by checking argv[0] of MSG_D_QUIT that will come. If you will be in shortcut session, no MSG_D_QUIT will be caused.

About the 0x20. Yes, if they didn't used shortcuts, why is the flag there? That's something to check. Anyway, I will add this to includes with adnotation that the name can be changed in future.

I hope to publish the snapshot tommorow (saturday).

Have a nice weekend too, m8.
yak

nuukiaworld
24-10-2005, 07:29 AM
The weekend is over :-( and the RPN_calculator version 0.4 is now available (link in the first message). It is now based on Yak's snapshot 22.10.2005. App is now almost complete, however, the following minor issues with the options menu are still present:

After selecting the angle unit with shortcut (e.g. 8-7-1), next time you enter third level of the menu (8-7... or 10-3...), the menu counter shows incorrect number even the dispmode 0x80 has been removed from the root menu. :-? (Same happens after setting the exchange rate, so it is somehow related to closing the whole menu after selection.) <solved in 1.0 with menu_close_all()>
Menu 10-3... disables shortcut processing but my app leaves the numeric keys enabled, so trying to enter shortcut 10-3-1 exits the app. <solved>

So we have still something to learn about utilizing shortcuts cleanly... :cool:

I tested also the way that the numeric keys are not NOP'ed during the menu. However, MSG_D_QUIT is unable to distinguish them from the Hangup key or long press on 'Back' -- all of them return argv[0] == 3. (Invalid shortcuts and angle unit shortcuts are trapped because they result in MSG_D_QUIT with argv[0] != 3.) Therefore I finally returned back to disable the number keys during the menu.

nuukiaworld
26-10-2005, 08:23 PM
menu_close() or MSG_CLOSE_MENU seem to close only the current level of (static) menus and leaves the parent levels (if any) in the menu "stack".

You can see this problem by removing the MCM_OWN_COUNTER of menu_options in rpn_calculator.nrx and then repeatedly selecting e.g. function 6 - 1 in the options menu. First time you enter the Options menu, the counter shows:
<path to RPN calc.>-1
which is correct.

After selecting 6 - 1 (manually or with shortcut), the app. closes the menu using MSG_CLOSE_MENU. Now open the Options menu again. Now you see different menu counter even you are exactly at the same "place":
<path to RPN calc.>-6-1

When you repeat this, the counter continues to grow:
<path to RPN calc.>-6-6-1
<path to RPN calc.>-6-6-6-1
when the counter contains five menus, the last position will be reused and the "Back" key starts to return you back to wrong menus.

How this can be avoided? The problem is that MSG_CLOSE_MENU removes only one menu level from the counter -- however, after selecting item 6 - 1 also the "Options" menu should be closed, not only the "Powers & roots" menu.

deadspot
29-10-2005, 01:41 AM
@nuukiaworld

possible to have all that function????

http://iphone-forum.org/viewtopic.php?t=49099

nuukiaworld
29-10-2005, 12:31 PM
Today's new version 0.5 of the RPN calculator (download link in the first message) contains a unit conversion function with 130 units in the following 16 groups:


Length (distance), Area, Volume, Time, Speed, Mass, Force, Energy, Power, Temperature, Pressure, Angle, Illuminance, Luminance, Equivalent dose, Radioactivity :D
If those are not enough, you may add more units by editing the convert_units.rx, it is in a rather simple format...

@deadspot
May be not all those features, I have only 13 kB flash left in my 6110. (If I had worked with a Series 60/80 phone, I would have already tried to port full HP48/HP49 emulator on that platform, instead of this small simple RPN calculator.)

nuukiaworld
31-10-2005, 08:32 PM
The first "release" version (1.0) of RPN Calculator is now available (link in the first post). There are no known bugs. Have fun!

I found the solution for the menu counter/backing problems: an unnamed menu function used by the built-in calculator's 'Exchange rate' submenu (I called it menu_close_all) clears "the menu stack" so that next time the Options menu is opened, it behaves exactly like in the first time.

You need to call this function if you close the menu without "backing" through the root level. For example, in RPN calculator, selecting an option in a submenu of the Options menu usually closes the menu completely! (In the official Nokix scripts there are no menus where selecting an item in a submenu directly closes the whole menu -- that's why this problem does not affect them.)

Did I find something new, or is this "menu_close_all()" function (see RPN calculator NRX/source) an alias for some well-known menu function? Anyway, great thanks to Yak who helped me a lot when developing this app. 8-)

joci2000
31-10-2005, 08:44 PM
:) :)

THANKS

:grin:

Regards

joci2000
01-11-2005, 10:35 AM
well the menu_close_all function is cannot be founded in 3310 :(
may be on 3310 there is different code isn't it?

i used this pattern on 3310 V6.07:

patt=x2c(B5304B95203018C049CB7809008A1885240070AC18D32231250A54D52900D102)

with this mask
mask=x2c(fffffff0fffffffffff0ffffffffffffffffffffffffffffffffffffffffffff)
and it seems work properly on 3330 also :)

nuukiaworld
02-11-2005, 12:28 PM
i used this pattern on 3310 V6.07:
patt=x2c(B5304B95203018C049CB7809008A1885240070AC18D32231250A54D52900D102)
Thanks for detecting this problem. I haven't tested, but by comparing the patterns I see that your pattern does not work on my 6110 V05.48 then. Would the common beginning of our patterns ( B5304B95203018C049CB7809008A1885240070AC18 ) be enough for reliable detection of the function on most flashes...?

If the function is really doing what I have understood, then I expect that the official LOCATE.RX will take care of locating it some day in the future and rename it with a more descriptive name (I couldn't invent any better one). I want to get rid of these potentially unportable patterns in my files as far as possible... ;-)

joci2000
02-11-2005, 01:48 PM
...
Would the common beginning of our patterns ( B5304B95203018C049CB7809008A1885240070AC18 ) be enough for reliable detection of the function on most flashes...?
...

in my opinion it would be enough ;) i tested it on some model and and it worked.

i used this patt and mask:

patt=x2c(B5304B95203018C049CB7809008A1885240070AC18D3
mask=x2c(fffffff0ff00fffffff0fffffffffffffffffffffff0)

bye

nuukiaworld
03-11-2005, 06:10 PM
I updated the menu_close_all (renamed to menu_reset) pattern according to your suggestion. (However, I had to add some more "holes" in the mask to make it 6110-V05.48-compatible.) The new version is 1.01.

I stopped using the new action_ok_back_close (sorry Yak! ;-) ): MSG_D_QUIT is sent when angle unit is selected with shortcut and has to be processed specially anyway. So I can detect manual menu closing also with MSG_D_QUIT instead of MSG_CLOSE_MENU (see source comments).

There is also one cosmetic change (new action action_none_back used when the "edit line" is empty); I hope this action it is compatible with other phones too!

joci2000
03-11-2005, 07:30 PM
...There is also one cosmetic change (new action action_none_back used when the "edit line" is empty); I hope this action it is compatible with other phones too!

well action_none_back action is not found in 3310 and nor in 3330 :sad:
may be a new action would be the solution :D

nuukiaworld
04-11-2005, 02:53 PM
Oops. I somehow expected that. I'll fix it after the weekend. Until that, you may use the following workaround to make RPN calc. V1.01 3310/3330-compatible:
...(clip)...

Now, the new version, 1.02 (link in the first post), solves this compatibility issue by using the same actions that 1.0 used. (I chose to allow OKing empty edit line because it is HP48-like behaviour.) I also added an HP48-like syntax checking so that you cannot anymore enter invalid numbers like -.E+, which appeared as zeros on the stack.

joci2000
08-11-2005, 03:15 PM
Thx this is great :D

and i have an idea for this great stuff: it would be great if there will be a number conversation function for different scale like:

dec2bin dec2hex dec2oct
bin2dec bin2hex bin2oct
hex2bin hex2dec hex2oct
oct2dec oct2bin oct2hex


regards

Daryl Saludares
09-11-2005, 01:27 AM
@ nuukiaworld
**********************************
# Processing started

# Input flash: 06.39F_INPUT_roden1.fls
# Loading... OK

# Processing: advanced_calculator.nrx
Done!

# Processing: rpn_calculator.nrx
Reversing the built-in calculator...
Adding unit conversion factors...
Conversion group with 22 units added.
Conversion group with 12 units added.
Conversion group with 21 units added.
Conversion group with 5 units added.
Conversion group with 7 units added.
Conversion group with 13 units added.
Conversion group with 6 units added.
Conversion group with 10 units added.
Conversion group with 3 units added.
Conversion group with 7 units added.
Conversion group with 4 units added.
Conversion group with 5 units added.
Conversion group with 3 units added.
Conversion group with 4 units added.
Conversion group with 2 units added.
Conversion group with 2 units added.
Adding the new application...
# ERROR: SETLONG: Bad arguments!
# 617 +++ setlong edit_o_1 str_syntax
# Error 4 running "C:\3310PPM0639B\scripts\rpn_calculator.nrx", line 617: Program interrupted

# ERROR: Script failure!
*******************************************
i downloaded the latest update, V1.02 of RPN and Nokix Script Snapshot 22.10.2005

nuukiaworld
09-11-2005, 07:27 AM
# ERROR: SETLONG: Bad arguments!
# 617 +++ setlong edit_o_1 str_syntaxYou have still some old RPN calculator files that have to been not updated to version 1.02. Delete all RPN calculator files and re-extract them from the V1.02 package. When updating RPN calculator (or any other Nokix script) to a new version, you need to extract at least all .nrx, .txt, and .rx files from the update package.

Daryl Saludares
10-11-2005, 01:03 AM
thank you...it's ok now, can you add a comma style to separate the 3 digits from the other digits e.g. 1,000.00, just a suggestion. :smile:

nuukiaworld
11-01-2006, 08:40 PM
it would be great if there will be a number conversation function for different scale like:

dec2bin dec2hex dec2oct
bin2dec bin2hex bin2oct
hex2bin hex2dec hex2oct
oct2dec oct2bin oct2hexI had already my own need for the different radixes in early November before your message. However, it was rather difficult feature to implement efficiently and user-friendly. For example, I needed to add the way of entering hexadecimal numbers in the input routies of the application. I left this project on hold for two months.

Finally, here you are: RPN Calculator version 1.10 (link in the first message of this thread).

I deviated a bit from the HP48's way of handling "binary integers". However, the display format is the same: # in the beginning and h, o, b at the end showing the radix. All arithmentic operators and functions are available in the hexadecimal, octal, and binary modes. However, fractional parts are ignored, and the negative values are displayed as 2's compelent.

To enter a hexadecimal (etc.) number, just begin the number by pressing # until the correct radix is displayed behind the cursor. The entered number is automatically converted to the display radix when placed on the stack. (This allows quick conversion from any radix to another.) To change the radix to be used for stack display, visit the new menu 9-8.

Hint: Visit also the new 'Bitwise logic' menu containing bit manipulation functions and operators. They can be used to manipulate normal decimal numbers, too!

joci2000
11-01-2006, 09:30 PM
:eek:

thx so much

deadspot
13-01-2006, 05:20 AM
@nuukiaworld

can u integrate your prn calc to plotter???..very nice combination!

nuukiaworld
13-01-2006, 07:23 AM
can u integrate your prn calc to plotter???..very nice combination!I have not tested this but I think it is simple: modify plotter.nrx as follows and ensure that rpn_calculator.nrx is processed before plotter.nrx in your NokiX project:
/* locating Calculator 5E0 ID */
patt=x2c(B510487D7804E00320012101F7CBF88520012101F7CBF83E2800D1F5)
mask=x2c(ffffff00fffffffffffffffff000f000fffffffff000f000ffffffff)
find x2d(200000) "patt" "mask"; make_calc_menu=rc
if vb>0 then say "Calculator menu creation function: 0x"d2x(make_calc_menu)
if make_calc_menu=0 then fail "Calculator menu creation function not found!"
findbl x2d(200000) make_calc_menu; addr=rc
getdata addr 1; findfunc addr "rc"; calculator=rc
call add_5e0_id
do id=1 to 255; if getenv("5e0_table/"id"/func")=calculator then leave; end
if id=255 then fail "Calculator 5E0 ID not found!"
calculator_id=id

/* use RPN calculator instead */
calculator_id=getenv("def/rpn_calculator/arg") /* add this! */


/* adding strings to PPM */
call add_ppm_strings "plotter_ppm.txt"

Daryl Saludares
13-01-2006, 10:27 AM
/* use RPN calculator instead */
calculator_id=getenv("def/rpn_calculator/arg") /* add this! */i just tried to insert the above lines, now it works fine... thanks :wink:

nuukiaworld
20-02-2006, 09:26 PM
I have added many new mathematical functions in the RPN calculator. Now it contains also such mathematical functions that are not present in the NokiX by default, so the patch installs also the required math library functions for calculating the following:
Hyperbolic functions (sinh, cosh, tanh, arcsinh, arccosh, arctanh)
More precise "exponent minus one" and "x+1's natural logarithm" required in some advanced formulas
Probability functions: combination (i.e. how many different ways you can pick seven balls from 39 balls => "39 7 COMB"), permutation, factorial (Gamma(x+1) function for non-integers), random number
Date calculations: add days to date, difference of two dates
Time/angle functions: add/subtract values in hours(degrees)-minutes-seconds format, convert from HMS to decimal and v.v.
Euro currency conversion in the unit conversion function (including the fixed rates for 12 old currencies)
There are also some size optimizations (trying to save flash!) and bug fixes.

Daryl Saludares
21-02-2006, 01:07 AM
as the RPN Calculator is more improving in functionality you are still very much particular with regards to the memory of our DCT-3's, thanks for some memory concern in the flash...thanks to "RESERVE_RAM.rx" macro too!
==================================
i suppose this line should be posted @ "script ideas thread" but i'd rather take this oppurtunity to suggest here, can you please write a separate script that will compress or if not totaly control the memory consumption in each nokix script in the processing list, like in my case i do make some cloning in screen_saver.nrx (13 screen savers w/ temp.), shutdown_animation.nrx (3 shutdown anim.), and welcome_animation.nrx (3 welcome anim.). with this maybe we could make use of the flash ("reserve_memory.nrx") :o for more upcoming scripts. sorry but i'm only an end user of your scripts, i don't know anything about programming or script writing. hoping for some considerations. ;)
==================================

regards ;-)

nuukiaworld
22-01-2007, 07:18 AM
RPN calculator has run so well on my phone for almost a year that I did know that its binary is not compatible with the current NokiX version. So here is a recompiled version of the application, including several other changes:

New for 1.21
- Compiled with SDK 2.41 - solves digit '9' problems with new NokiX
- Fixed "Domestic unit expressed as foreign units" dialog
- Fixed main script to allow leaving out the unit conversion function
- Added "Source unit selected" message in unit conversion
- Added Slovenian tolar (SIT) in Euro currency conversion group
- Renamed Percentages to Quotients, added GCD and LCM

Download link in the first post. Enjoy! :-D Please continue giving ideas and feedback.

joci2000
23-01-2007, 01:43 PM
thanks the update for this amazing calculator ;)

My phone can calculate almost everything what my standard calculator.:lol:

But may somewhen is it possible to add some important statistics functions for all value which is in the stacks? I mean like calculate average, spread, modus, median...etc. for the values which are in stack. I think this also can be useful, but may not for everyone:roll: . In my school it would be very useful.

nuukiaworld
28-01-2007, 05:09 PM
My phone can calculate almost everything what my standard calculator.:lol:I do my best to exceed that.

But may somewhen is it possible to add some important statistics functions for all value which is in the stacks? I mean like calculate average, spread, modus, median...etc. for the values which are in stack.
I had considered this for a long time already. However, HP48 uses a special variable ΣDAT to store the data for statistical calculations and did not want to introduce other memory storage than the stack in this tiny RPN calculator.

Your idea to use the stack for the statistical data solves this problem! The downside is that it is difficult to calculate complex calculations with the statistical figures because there must not be any other data in the stack when executing any of the new statistical functions. And it still lacks the problematic figures median and mode... :( But it is now better than nothing. (Download link for 1.30 in the first message of this thread.)

Another important improvement is the use of the new realloc_try() that prevents the phone hanging when the stack grows too much. Instead, an error message is displayed. (Fun: I can fill grow the stack to 88 levels on my 6110 by holding the down arrow [DUP] pressed. How many levels fit in your phone RAM? :cool: )

joci2000
28-01-2007, 06:28 PM
Great update. Thanks so much.

To calculate median isn't hard but for that you have to sort the numbers by growing. This is the hard part. :(

After this median can calculate easily.

if N=2k+1 me=(N+1)/2nd X

but if N=2k

me=1/2*{ (N/2)nd X + [(N/2)+1st] X}

I hope i was understandable.

The calculate of mod is a little bit difficult because for it we need frequency. For frequency we need intervals(if we have standalone values without frequences). But how many intervals we need it's up to us. The mode is the value which has the highest frequency.

And about 3310's stack level: With 1234567890 number i can fit up to level 736. (I duplicated 100 numbers till i get not enough memory and after i duplicated 50, 10, 2, 1 number till i get out of memory :D)

BlinK_
04-02-2007, 08:54 PM
I get en error when I try to add RPN calculator into my project. I tried to add ONLY RPN calculator to such 3310 flash files: 5.79, 6.07, 6.39, and always I get same error:

# Processing started

# Input flash: 3310_NHM5_06.39.fls
# Loading... OK

# Processing: rpn_calculator.nrx
Patching...
Reversing the built-in calculator...
# ERROR: STR_CONVERT_UNITS: Unknown object!
# 228 +++ fail func": Unknown object!"
# 518 +++ call ezmenu "add",m,locate("str_convert_units"),x2d(387),menu_units,,action
# Error 4 running "E:\Martyno\Nokia\NokiX_main\NokiX\scripts\LOCATE.rx", line 228: Program interrupted

# ERROR: Script failure!


What is the problem?

nuukiaworld
04-02-2007, 09:29 PM
To calculate median isn't hard but for that you have to sort the numbers by growing. This is the hard part. :(
Yes, the problem is in sorting but... sorting itself is not a problem but doing temporary sorting without any extra memory is impossible. The calculator must not sort or touch the data in the stack in any way. (This is because I have defined that all statistical functions do not "eat" their arguments!)

Mode is actually simpler to find but it is not always unique. RPN Calculator does not support vectors or lists, so it cannot return more than one number as a result of a function.

Anyway, I added these functions to version 1.31, although it took about ½ kB of flash space. The algorithms in calc.c are my own designs, based on repeated looping through all the values but it will not be a problem with the amounts of data that the stack can hold. *

* Although 3310 can hold ten times more data than 6110. :P

BTW. Each value (IEEE double) in the stack takes 8 bytes of memory. When stack is expanded, the realloc_try() will reserve first new memory space for the whole stack before freeing the old one. So, when Out of memory appears, the stack is going to grow larger than the largest available block of free space. There may be a lot of free space, still.

nuukiaworld
04-02-2007, 09:35 PM
# ERROR: STR_CONVERT_UNITS: Unknown object!
You are missing some RPN calculator files. There should be one *.nrx file, one *.rx file, and two *.txt files:

rpn_calculator.nrx
rpn_calculator_ppm.txt
convert_units.rx
convert_units_ppm.txt

All these files should be automatically available if you extract the whole rpncalc.zip archive in a folder.

If you tried intentionally to leave the unit conversion function out, then you need only rpn_calculator.nrx and rpn_calculator_ppm.txt, but in that case you will need to comment out the marked section in rpn_calculator.nrx.

nuukiaworld
27-12-2007, 09:43 PM
Hello, this is my last and biggest update of this autumn. After this I am again satisfied with my phone, and I suspend my NokiX development again (until something needs to be changed). (I hope that next time I join the NokiX development team on SourceForge before doing anything. But let's see when that happens.)

The brand-new RPN calculator version (1.40) features a large library of fundamental physical constants (based on NIST's CODATA 2006 values). Also seven new units have been added to the unit conversion function, for example dBm for RF people and different angular mils for artillery guys :-P. This application shows that your Nokia can be a full-featured calculator for scientific purposes! :D


http://www.panuworld.net/nuukiaworld/download/nokix/const1.gif http://www.panuworld.net/nuukiaworld/download/nokix/const2.gif http://www.panuworld.net/nuukiaworld/download/nokix/const3.gif

If you do not need to amaze your friends with the 151 units and 88 constants, you can now easily leave these features out and save some flash space (just set parameters NO_UNITS NO_CONSTANTS for the rpn_calculator.nrx script).

Some other small changes have been also done, check the .nrx file for more information. There were even some bugs, which have been fixed.

I hope that you enjoy your "scientific Nokia"! :P The download link can be found in the first message of this thread.

nuukiaworld
01-02-2008, 09:39 PM
Version 1.41 fixes the following minor problem:
At normal stack mode, press Options
Enter shortcut 13 (Constants)
Wait until the Constants menu is shown
Press OK before the shortcut timeout expires, this ends the possibility to enter further shortcuts
Press any number (or *, #) and phone goes directly to the standby mode
Instead, the number keys should be NOPed in the menu when shortcuts are not available anymore. Pressing numbers in the menu should not close the calculator (like in the standard calculator).

nuukiaworld
09-03-2008, 01:57 PM
Version 1.42 fixes the incorrect behavior when entering a decimal value with very small/large exponent, e.g. 1.E2147483648. Now the value correctly underflows to zero or Out of range is displayed depending on the exponent sign.

nuukiaworld
01-01-2009, 07:16 PM
Hello nobody :razz:,

To celebrate the new year 2009, I finally tested my latest fixes to the RPN Calculator, originally written already in April. Those fixes have been now released as version "1.43". (Download link in the first message of this thread.)

Summary of changes:
Fixed hang with large exponent and zero mantissa, e.g. 0.E99999999999
Corrected unit conversion to dBm (returned 1/100 of correct result)
Fixed base if in DEC mode, empty stack, and # pressed after start-up

NB! The package contains both the source and compiled NokiX script. If you want to separate the compiled script files from the sources, note that six (6) files must be present in order to use the RPN Calculator script with NokiX: rpn_calculator.nrx, rpn_calculator_ppm.txt, contants.rx, constants_ppm.txt, convert_units.rx, convert_units_ppm.txt. Do not remove these files if you want to remove the source code from the actual script!

deadspot
05-01-2009, 12:54 PM
heheheh...still some people here sir...

dvirus666
12-01-2009, 05:16 PM
Well hello from nobody. (IMHO I thoought this place a dead :-o)

Nice work nuukiaworld. Good to see scripts still coming.

druidbartek
03-03-2009, 02:34 AM
whoah, dead like me ;)

nice to hear some news from You guys - I stopped visit this site from obvious reason ;)

for those who dont know yet - NokiX main site was officially moved (by Yak) to sourceforge.
http://nokix.sourceforge.net/ is now the official address - old one still works but some problem may occasionally occurs...

well, the page still needs to be updated but some works has been done, like updating of sdk documentation (0.95), reorganizing archive and some less visible

Likewise, some packages has been released too (not mentioned at nokix download page yet but can be obtained directly from https://sourceforge.net/projects/nokix/). You'll find here NokiX 1.39, SDK 2.45 and some tools and scripts updates too. Well, changes are not documented yet (only in repository logs), hope to some stuff will be still usefull.

im going to bed so n8 all


ah - scripts package contain scripts those from Yak, and some 3rd party too - if the source code is available, so dont be surprise You will find yours rpncalc app inside - dont beat me, I was thinking everyone's dead :D

nuukiaworld
03-03-2009, 06:55 AM
ah - scripts package contain scripts those from Yak, and some 3rd party too - if the source code is available, so dont be surprise You will find yours rpncalc app inside - dont beat me, I was thinking everyone's dead :DNo problem, they are under GPL. And it is very good that all scripts are available on one place, otherwise they might got lost. May be some day I'll upgrade my setup to the new NokiX SDK, let's see.

druidbartek
03-03-2009, 09:38 AM
No problem, they are under GPL. And it is very good that all scripts are available on one place, otherwise they might got lost. May be some day I'll upgrade my setup to the new NokiX SDK, let's see.

only those under GPL (at least those with sources) are released as scripts package.

other ones, like great pills game, display_date or spymode, can be downloaded from NokiX archive NokiX (http://nokix.sourceforge.net/?type=archive&lang=en) (all scripts uploaded there was carefully reviewed)

well, last year was the worst period at NokiX scene - hope that fifth birthday of NokiX (15.06) will bring a lot of new stuff :)

deadspot
05-03-2009, 02:26 AM
only those under GPL (at least those with sources) are released as scripts package.

other ones, like great pills game, display_date or spymode, can be downloaded from NokiX archive NokiX (http://nokix.sourceforge.net/?type=archive&lang=en) (all scripts uploaded there was carefully reviewed)

well, last year was the worst period at NokiX scene - hope that fifth birthday of NokiX (15.06) will bring a lot of new stuff :)

nice hearing about new update of nokix!!!!

BlinK_
17-03-2009, 11:25 PM
One more alive nokix user here. (: Nice to hear that things move along there.

nuukiaworld
12-02-2010, 07:47 PM
Hello again, nobody!

The 2010 version of RPN calculator fixes one bug related to calls during calculator use. It also add the Slovakian koruna in the Euro currency list.

Download link in the first message of this thread, as usual.

nuukiaworld
07-10-2010, 07:51 PM
So many times I have calculated some values on the RPN's stack and then, at the last operation, selected accidentally wrong operator from the Options menu. If you accidentally multiply instead of divide, it is impossible to get back the operands back and do the correct operation.

But not anymore! Version 1.50 includes full Undo function (HP users may know it also as "Last Stack"). By selecting Undo in the Options menu the stack is restored back to the situation before last successful operation. This makes it possible to continue calculation even after a wrong operation. On NuukiaWorld's RPN Calculator, undo is available also in the interactive stack mode; thing that you cannot do e.g. on HP48 series calculators!

Other changes in this new version:
Fixed radix when pressing # while editing a value in stack (DEC mode)
Fixed incorrect display of e.g. 99999999.5 as 10E7 instead of 1E8
Fixed unnecessary scientific display of e.g. -1.1E-6 (-0.0000011)
Patched Nokia's ftoa() bug: e.g. 25000000.1 was displayed as 25000000.
Added Estonian kroon (EEK) in Euro currency conversion group