How to enter a variable in an INPUT ?
12-06-2019, 09:31 PM (This post was last modified: 12-07-2019 07:19 PM by What_Else.)
Post: #1
 What_Else Junior Member Posts: 6 Joined: Dec 2019
How to enter a variable in an INPUT ?
Hello, I bought an HP Prime there is very little time!
I wanted to test the HP Prime Basic language by doing a vector product calculation program.
The problem is that I can not at all include variables in INPUT (I wish I could enter 4x for example instead of 4)
Code:

EXPORT Produit_Vectoriel()
BEGIN

LOCAL A,B,C,D,E,F;
LOCAL X,Y,Z,N;

INPUT({A,B,C},"Vecteur 1",{"X = ","Y = ","Z = "});

INPUT({D,E,F},"Vecteur 2",{"X' = ","Y' = ","Z' = "});
CAS("B*F*-C*E▶X");
C*D-A*F▶Y;
A*E-B*D▶Z;
CAS("sqrt(X^2+Y^2+Z^2)▶N");

PRINT();
PRINT(" ");
PRINT(" Résultat :");
PRINT(" |"+X);
PRINT(" |"+Y);
PRINT(" |"+Z);
PRINT(" ");
PRINT(" Norme : "+N);

END;

Thank you
12-07-2019, 10:14 PM
Post: #2
 Dougggg Member Posts: 93 Joined: Dec 2013
RE: How to enter a variable in an INPUT ?
If you do input as a string you can use the EXPR() command

EXPR("4*X");
12-07-2019, 10:48 PM (This post was last modified: 12-07-2019 11:00 PM by What_Else.)
Post: #3
 What_Else Junior Member Posts: 6 Joined: Dec 2019
RE: How to enter a variable in an INPUT ?
(12-07-2019 10:14 PM)Dougggg Wrote:  If you do input as a string you can use the EXPR() command

EXPR("4*X");

Have I to put that in the code of the program, or when I use it ?
In fact, my program works, I would just like to know how to integrate variables into the calculation (i don't know if that's the good method)

12-09-2019, 03:11 AM
Post: #4
 Dougggg Member Posts: 93 Joined: Dec 2013
RE: How to enter a variable in an INPUT ?
here is an example that worked for me to input a formula with variables in the input command:

INPUT({X,{FF,[8]}});
Y:=EVAL(FF);

If that is your question
12-09-2019, 06:29 PM
Post: #5
 What_Else Junior Member Posts: 6 Joined: Dec 2019
RE: How to enter a variable in an INPUT ?
(12-09-2019 03:11 AM)Dougggg Wrote:  here is an example that worked for me to input a formula with variables in the input command:

INPUT({X,{FF,[8]}});
Y:=EVAL(FF);

If that is your question

The program does'nt start with these lines, where do i should put there ?
12-10-2019, 04:06 AM
Post: #6
 Dougggg Member Posts: 93 Joined: Dec 2013
RE: How to enter a variable in an INPUT ?
That was just example of how to do the input statement to accept a string, your variables maybe different
12-10-2019, 06:15 PM
Post: #7
 CyberAngel Member Posts: 296 Joined: Jul 2018
RE: How to enter a variable in an INPUT ?
(12-09-2019 03:11 AM)Dougggg Wrote:  here is an example that worked for me to input a formula with variables in the input command:

INPUT({X,{FF,[8]}});
Y:=EVAL(FF);

If that is your question

[8] TYPE string
can be evaluated to other suitable types
12-10-2019, 06:40 PM
Post: #8
 What_Else Junior Member Posts: 6 Joined: Dec 2019
RE: How to enter a variable in an INPUT ?
(12-10-2019 06:15 PM)CyberAngel Wrote:
(12-09-2019 03:11 AM)Dougggg Wrote:  here is an example that worked for me to input a formula with variables in the input command:

INPUT({X,{FF,[8]}});
Y:=EVAL(FF);

If that is your question

[8] TYPE string
can be evaluated to other suitable types

Do you have any example, like a little program with these lines ?
 « Next Oldest | Next Newest »

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