HP 40gs HP 39gs_40gs_Mastering The Graphing Calculator_English_E_F2224-90010.p - Page 277
very important technique., A copy of
UPC - 882780045217
View all HP 40gs manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 277 highlights
The second and third lines insert a function into F1(X). This can only be done, of course, if the parent aplet is Function. If you do this when the parent is another aplet then the code will still execute but the function will be inserted into the real Function aplet! The reason for inserting this particular function is that we need a function when the axes are plotted or the normal error message will be displayed (see above right). This is undesirable because it will confuse the user. On the other hand we need blank axes for later use in exploring, so we use a trick - we set the function being inserted to be 'Ymax+1'. This is a constant linear function, a horizontal line, which is guaranteed to be off-screen for the entire domain no matter what axes are used vertically. Clever, eh? The next program code we will look at belongs to the 1st option on the VIEWS menu of 'Plot axes'. A message is first given to the user of how to proceed if they want to use different axes. The flag value of G is then set to 1 so that the next program can tell that the axes are ready to use. The function is also re-entered in case the user has changed the SYMB view. Users have an annoying habit of changing things so try to allow for this in your programs by making them fool-proof. The next program below runs when the user chooses the second menu option of "Explore", and illustrates a very important technique. A copy of the PLOT view is stored in the aplet's sketch view and then retrieved and modified using the various graphics commands. The program is broken into parts for discussion purposes. The reason for the "IF G==0 THEN" is to check that the blank axes have been plotted and are available for use. If not then the user receives a message to tell them what to do and the remainder of the program is bypassed using the IF...THEN...ELSE statement. Trying to capture a PLOT view that doesn't exist is a major error and will result in the program crashing abruptly. It is possible to allow for errors like this using the IFERR statement but in a teaching example like this it makes the code more difficult to follow. 277