Error: Invalid Input on my program
|
01-17-2017, 12:39 AM
Post: #1
|
|||
|
|||
Error: Invalid Input on my program
Hello, and thanks for answering, I'm new to the forum so please tell me if this is the wrong sub-forum.
I recently got an HP Prime, I can't believe how simple it is programming it, however I encountered a few problems when creating a UI for input. I made a program based on style 2 of: http://www.hpmuseum.org/forum/thread-455.html The code for my program is: Code:
The program passes the check. The problem arises when the program is running; when I try to input the first algebraic function (between simple quotes), I get the message: "Error: Invalid Input", even if I try to input something as simple as a parabola. Am I doing something wrong? Is there something my program is missing? Thanks for your help. |
|||
01-17-2017, 02:47 PM
(This post was last modified: 01-17-2017 03:03 PM by StephenG1CMZ.)
Post: #2
|
|||
|
|||
RE: Error: Invalid Input on my program
I think that one problem may be that the INPUT syntax has changed since Han wrote that in 2013.
Briefly, where previously one would have INPUT... varname, now one should use IINPUT...{{varname,[numbers]}} Where numbers specifies the type of input, for example INPUT...{{varname,[3]}} might specify string, or 6 might specify list, or 3,6 would be either. The number you want is probably (DOM_STRING-1). Check the INPUT help for the exact syntax. (But if you are using CAS input, I don't know). Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
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 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)