Division by 0 (zero) in an App
|
03-26-2017, 09:48 PM
Post: #1
|
|||
|
|||
Division by 0 (zero) in an App
Most of the programming I've done has been with Apps. In a "hpprgm", division by 0 is flagged as "X\0". In an App, it dumps you to the home screen, and tells you nothing. It also appears, that in general, the error messages on programming mistakes are not as good on the Apps programming side, as they are on the regular programming side (hpprgm). The division by 0 anomaly has existed for a long time. I was wondering if improving App error message creation is at least being considered?
|
|||
03-27-2017, 06:59 AM
Post: #2
|
|||
|
|||
RE: Division by 0 (zero) in an App
(03-26-2017 09:48 PM)Bob Frazee Wrote: Most of the programming I've done has been with Apps. In a "hpprgm", division by 0 is flagged as "X\0". In an App, it dumps you to the home screen, and tells you nothing. It also appears, that in general, the error messages on programming mistakes are not as good on the Apps programming side, as they are on the regular programming side (hpprgm). The division by 0 anomaly has existed for a long time. I was wondering if improving App error message creation is at least being considered? Apps do not have any means of returning results, including error messages, unlike non-app programs. You can still debug an app by inserting DEBUG statements into your code. This will trigger the debugger to help you trace the errors. That said, if you need to trap errors, consider IFERR blocks. But in sum, you are right -- apps require you to be much more vigilant about making sure your code behaves as intended from the design stage. Graph 3D | QPI | SolveSys |
|||
03-28-2017, 05:55 AM
Post: #3
|
|||
|
|||
RE: Division by 0 (zero) in an App
Hello,
Note that you can test your faulty app program function by exporting it and calling it directly from the command line. At this point, it will behave like a normal program. Do not hesitate to use the build in debuger either using debug(function) or by placing a breakpoint in your program using the debug; instruction in said program. Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
03-28-2017, 11:37 PM
(This post was last modified: 03-28-2017 11:40 PM by Bob Frazee.)
Post: #4
|
|||
|
|||
RE: Division by 0 (zero) in an App
Hi Cyrille;
Well, I tried your above suggestion. App Name: HeatIndex Inside App: EXPORT Heatindex() Go to home screen Select: Toolbox, then App, then HeatIndex->HeatIndex I now have HeatIndex on the command line I hit Enter. App does not start. All it does is shift HeatIndex above the command line and displays 0.0000 It does the same thing if I use HeatIndex(). It also does the same thing if I take the divide by 0 out of the App. Am I doing something wrong? |
|||
03-28-2017, 11:47 PM
Post: #5
|
|||
|
|||
RE: Division by 0 (zero) in an App
(03-28-2017 11:37 PM)Bob Frazee Wrote: Hi Cyrille; Was the app designed to start using the HeatIndex() program? In other words, how do you normally start your app? Usually, apps are "run" using one of the following physical keys: Plot, PlotSetup, Num, NumSetup, Symb, SymbSetup, View, or Info. Additionally, the app can also be "run" by using the Apps key, selecting the app, and choosing "Start" from the touchscreen menu. However, each of these buttons do (possibly) different things depending on the code definition for Plot(), PlotSetup(), etc. So unless those functions directly and immediately call HeatIndex(), then of course nothing will run. Also, when you wrote "Inside App: EXPORT HeatIndex" -- was this to mean that you added EXPORT in front of HeatIndex inside the source code file? Graph 3D | QPI | SolveSys |
|||
03-29-2017, 05:44 AM
Post: #6
|
|||
|
|||
RE: Division by 0 (zero) in an App
Hello,
What does the HeatIndex function contain? Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
03-30-2017, 12:45 AM
Post: #7
|
|||
|
|||
RE: Division by 0 (zero) in an App
Cyrille wrote;
"What does the HeatIndex function contain?" Code:
|
|||
03-30-2017, 01:15 AM
Post: #8
|
|||
|
|||
RE: Division by 0 (zero) in an App
It is fairly evident that the HeatIndex() function does absolutely nothing since there is no code there (just an empty BEGIN END; block).
The actual code that starts your app is the START() function that has been _ALSO_ duplicated as a [View] menu item, listed as "Start HeatIndex". So the function you want to export (if that is in fact what you want to do) is the START() function. Graph 3D | QPI | SolveSys |
|||
04-02-2017, 08:06 PM
Post: #9
|
|||
|
|||
RE: Division by 0 (zero) in an App
Han wrote;
"In other words, how do you normally start your app?" I typically start it by either tapping on the "HeatIndex" App screen icon or highlighting the App screen icon and hitting the "Enter" key. I presume that HeatIndex() starts the program, and even though it appears to do nothing, the BEGIN END pair has to be there, or the App will not run. If it actually does nothing, then it should execute the next instruction, which is the VIEW command. The order of this App follows the DiceSimulation() App example on p 579 of the manual. Cyrille wrote; "Note that you can test your faulty app program function by exporting it and calling it directly from the command line. At this point, it will behave like a normal program." So in this case, Han is correct?, I should export START()? How do I do that, since it is part of the View command? Do I need to structure my App differently than the example in the manual in order to use the code troubleshooting method Cyrille suggested? |
|||
04-02-2017, 10:39 PM
Post: #10
|
|||
|
|||
RE: Division by 0 (zero) in an App
(04-02-2017 08:06 PM)Bob Frazee Wrote: Han wrote; This suggests that the START() function is where your app gets run. The code you posted confirms this. Quote:I presume that HeatIndex() starts the program, and even though it appears to do nothing, the BEGIN END pair has to be there, or the App will not run. If it actually does nothing, then it should execute the next instruction, which is the VIEW command. The order of this App follows the DiceSimulation() App example on p 579 of the manual. In this case, where you have the START function defined with the VIEW command, I would simply rename it and create a wrapping START function. Code:
Now, you can add EXPORT in front of START and debug normally. Or, you can optionally just insert the DEBUG command anywhere in your code where you wish to start the debugging process. I find this second method much easier. By using multiple calls to the DEBUG command, I "skip" unnecessary debugging steps using the "continue" option, which runs the app/program up until the next instance of DEBUG. Graph 3D | QPI | SolveSys |
|||
04-03-2017, 11:44 PM
Post: #11
|
|||
|
|||
RE: Division by 0 (zero) in an App
Thankyou Han for your explanation. I took your examples and modified them a little, and this is what I ended up with;
Code:
So back to my original question to the Hp group; The division by 0 anomaly in an App has existed for a long time. I was wondering if improving App error message creation is at least being considered? |
|||
04-04-2017, 03:52 AM
Post: #12
|
|||
|
|||
RE: Division by 0 (zero) in an App
Encapsulate your routines in an IFERR block; use Ans(0) to get the error number, if there was an error.
Code:
Only slightly more useful; division by 0 is error number 4. Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)