Post Reply 
Error: Invalid Input on my program
01-17-2017, 04:14 PM (This post was last modified: 01-18-2017 12:14 PM by Han.)
Post: #3
RE: Error: Invalid Input on my program
INPUT() has gone through a number of changes since that post. There are two ways to get around the issue you have:

1) Initialize your f and f1 to objects of the type you wish to use in the INPUT() command. When you do not initialize them, then they are set to the value 0 by default (type: real number). Thus, when a user then enters something that is not a real number, the INPUT() command complains of invalid input. You can, for example, set f:='X^2-5' and f1:='2*X' before the INPUT() command, and then it will expect an algebraic expression.

2) The other method use the more advanced form of INPUT() to enforce the input type for each field (i.e. f and f1 and be required to expect an expression). The help screen for INPUT() explains everything you need to make use of the advanced form.

There is yet another bug in your program, though. You have a line: M0:={}. While technically incorrect (because M0 is a vector/matrix and not a list), the HP Prime will happily convert the empty list into a vector and insert at least a 0 -- the built-in variables may not be "empty" so it auto-fills the first value with 0. The problem, however, is that you are using M0 as a matrix. So you will get yet another error when your program reaches this point. Instead, initialize M0 using: M0:=[[0]]; and your program should be fine (this makes M0 a matrix and not a vector).

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Error: Invalid Input on my program - Han - 01-17-2017 04:14 PM



User(s) browsing this thread: 1 Guest(s)