Understanding variables relative to the current active App
|
01-05-2014, 07:07 PM
Post: #5
|
|||
|
|||
RE: Understanding variables relative to the current active App
(01-05-2014 05:14 PM)Michael de Estrada Wrote:(01-05-2014 03:38 PM)Han Wrote: It is natural for an app's angle settings to override the system settings. You don't have to change apps. As you noted, an app is always active. The HAngle is the default system-wide setting (I believe for both Home and CAS) that is the fall-back for all apps when AAngle is set to 0. That is, AAngle:=0 means use the system-wide HAngle setting. In terms of scope, an app runs inside the system-wide environment. So it must obey HAngle when AAngle is set to 0. Similarly, if you write a program -- it runs inside an app environment at any given time. So your program must likewise obey the hierarchy: first, it must obey AAngle, and if AAngle is 0, it must adhere to HAngle. Quote:Let's say your current active App has set the angle mode to degrees, but you are executing a program that requires radians, so it has the the statement HAngle:=1 that never gets executed because AAngle:=2 in the App. Which is exactly as designed. A program runs inside an app, and an app inside the entire system. So in terms of scope, the program's angle mode is first determined by AAngle and only only falls back onto HAngle when AAngle is 0. The issue you are raising is no different between program-inside-an-app vs app-inside-the-system. Quote:Your program fails to run correctly and you are scratching your head wondering why this has happened. IMO, what would be natural is for the program to at least temporarily override the angle setting during its execution. The failure of your program to run on every single combination of settings is not strong argument for changing the current design. A program should ideally run under all conditions, and its failure to do so is more often due to its author overlooking minute details. This may be a difference in programming philosophy, but programs should avoid ever changing user's settings. In other calculators (and even the HP Prime), one can easily temporarily back up the user's settings and restore it. However, it is almost always possible to interrupt a program (without any lower-level hacking/programming) in such a way that the program never actually restores the user's settings. Taking the angle mode as an example, there are ways to avoid ever having to deal with changing a user's settings. Instead, your program should read the user's settings and handle it accordingly. If you prefer to use values associated with radian measure, then write a small subroutine that changes your programmed values to the appropriate angle based on the user's settings instead of changing the user's settings to match your programming style. To use a PC analogy: If you are writing a web page only uses java script, and your page shows up wrong because a user turned off javascript, should your code turn on the user's javascript -- even only temporarily to display your web page -- and then turn it off? Or should your web page be designed to account for no java script settings? I wrote sample code on how to bypass all the issues with the angle mode though it is limited to only HAngle. It would not be difficult to adjust it to account for AAngle as well. Code:
If you would rather temporarily change a user's settings, however, then change AAngle within your program, not HAngle. And of course, make sure to restore it so you don't break the app (though the author of such an app should likewise code in such a way that this shouldn't be an issue). Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Understanding variables relative to the current active App - Michael de Estrada - 12-27-2013, 10:51 PM
RE: Understanding variables relative to the current active App - Michael de Estrada - 01-05-2014, 03:27 PM
RE: Understanding variables relative to the current active App - Han - 01-05-2014, 03:38 PM
RE: Understanding variables relative to the current active App - Michael de Estrada - 01-05-2014, 05:14 PM
RE: Understanding variables relative to the current active App - Han - 01-05-2014 07:07 PM
RE: Understanding variables relative to the current active App - Han - 01-05-2014, 07:21 PM
RE: Understanding variables relative to the current active App - Michael de Estrada - 01-05-2014, 07:31 PM
RE: Understanding variables relative to the current active App - Han - 01-05-2014, 07:45 PM
|
User(s) browsing this thread: 1 Guest(s)