Post Reply 
input issues
01-25-2021, 02:07 PM (This post was last modified: 01-25-2021 02:12 PM by Amer7.)
Post: #1
input issues
Hi, I'm struggling with simple stuff

How do I actually ask for like: Input σ₁², and to store that number in like a1? I couldnt get to show symbols like σ₁², and when i ask to store it in a1 I have a syntax error ?

I got it like this INPUT(A, "", "Input σ₁²");
INPUT(B, "", "Input σ₂²");
INPUT(C, "", "Input σ₁₂");
INPUT(F, "", "Input F(α,2,f)");

To work
How do i make these display, one under other in input screen.
Find all posts by this user
Quote this message in a reply
01-25-2021, 02:38 PM (This post was last modified: 01-25-2021 02:42 PM by Didier Lachieze.)
Post: #2
RE: input issues
Here is a simple example:

Code:
EXPORT Test()
BEGIN
 LOCAL a1;
 INPUT(a1,"Input test", "σ₁²");
 PRINT(a1);
END;

You can find σ in the Chars table (Shift Vars) under More>Greek and Coptic
and the lower script 1 and upper script 2 in the same table under More>Subscript/Superscript

For several variable inputs you can do:

Code:
EXPORT Test()
BEGIN
 INPUT({A,B,C,D},"Input test", {"Input σ₁²","Input σ₂²","Input σ₁₂","Input F(α,2,f)"});
 PRINT({A,B,C,D});
END;

Look in the HELP for more details about INPUT which has a lot of options to build complex input forms. You can access the HELP in several ways:
  • directly through the Help Key and then searching for INPUT,
  • by pressing the HELP after selecting INPUT in the Toolbox catalog,
  • or pressing HELP after positioning the cursor on the INPUT keyword in your program.

Note that these examples assume numeric inputs. If you want some inputs such as F(α,2,f) to be alphanumeric you need to specify the allowed types for each variable as described in the HELP.

For example :

Code:
EXPORT Test()
BEGIN
 LOCAL a,b,c,d;
 INPUT({{a,[0]},{b,[0]},{c,[0]},{d,[2]}},"Input test", {"Input σ₁²","Input σ₂²","Input σ₁₂","Input F(α,2,f)"});
 PRINT({a,b,c,d});
END;


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
01-25-2021, 03:13 PM
Post: #3
RE: input issues
(01-25-2021 02:38 PM)Didier Lachieze Wrote:  Here is a simple example:

Code:
EXPORT Test()
BEGIN
 LOCAL a1;
 INPUT(a1,"Input test", "σ₁²");
 PRINT(a1);
END;

You can find σ in the Chars table (Shift Vars) under More>Greek and Coptic
and the lower script 1 and upper script 2 in the same table under More>Subscript/Superscript

For several variable inputs you can do:

Code:
EXPORT Test()
BEGIN
 INPUT({A,B,C,D},"Input test", {"Input σ₁²","Input σ₂²","Input σ₁₂","Input F(α,2,f)"});
 PRINT({A,B,C,D});
END;

Look in the HELP for more details about INPUT which has a lot of options to build complex input forms. You can access the HELP in several ways:
  • directly through the Help Key and then searching for INPUT,
  • by pressing the HELP after selecting INPUT in the Toolbox catalog,
  • or pressing HELP after positioning the cursor on the INPUT keyword in your program.

Note that these examples assume numeric inputs. If you want some inputs such as F(α,2,f) to be alphanumeric you need to specify the allowed types for each variable as described in the HELP.

For example :

Code:
EXPORT Test()
BEGIN
 LOCAL a,b,c,d;
 INPUT({{a,[0]},{b,[0]},{c,[0]},{d,[2]}},"Input test", {"Input σ₁²","Input σ₂²","Input σ₁₂","Input F(α,2,f)"});
 PRINT({a,b,c,d});
END;

I see I have to use LOCAL to to use variables like a1,b,c,d etc.
What if i want to calculate like R = a+b+c and later
PRINT ({R});
Do I have to define R in local or can i just go like this
LOCAL a,b,c,d;
INPUT({{a,[0]},{b,[0]},{c,[0]},{d,[2]}},"Input test", {"Input σ₁²","Input σ₂²","Input σ₁₂","Input F(α,2,f)"});

R= a+b+c;
PRINT({R});

Will this work ?
Find all posts by this user
Quote this message in a reply
01-25-2021, 03:47 PM
Post: #4
RE: input issues
(01-25-2021 03:13 PM)Amer7 Wrote:  I see I have to use LOCAL to to use variables like a1,b,c,d etc.
What if i want to calculate like R = a+b+c and later
PRINT ({R});
Do I have to define R in local or can i just go like this
LOCAL a,b,c,d;
INPUT({{a,[0]},{b,[0]},{c,[0]},{d,[2]}},"Input test", {"Input σ₁²","Input σ₂²","Input σ₁₂","Input F(α,2,f)"});

R= a+b+c;
PRINT({R});

Will this work ?

Try it???

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
01-25-2021, 03:53 PM
Post: #5
RE: input issues
(01-25-2021 03:47 PM)rprosperi Wrote:  
(01-25-2021 03:13 PM)Amer7 Wrote:  I see I have to use LOCAL to to use variables like a1,b,c,d etc.
What if i want to calculate like R = a+b+c and later
PRINT ({R});
Do I have to define R in local or can i just go like this
LOCAL a,b,c,d;
INPUT({{a,[0]},{b,[0]},{c,[0]},{d,[2]}},"Input test", {"Input σ₁²","Input σ₂²","Input σ₁₂","Input F(α,2,f)"});

R= a+b+c;
PRINT({R});

Will this work ?

Try it???

It doesn't work, it seems that you have to define all of your variables at the start. This is not very practical. Is there a way that I can define new variables as I go. I'm not sure how many i will need.
Now I see why most people decide for other brands of calculators that are even slower. You dont have to be a programmer to write a simple program.
Find all posts by this user
Quote this message in a reply
01-25-2021, 04:03 PM
Post: #6
RE: input issues
(01-25-2021 03:53 PM)Amer7 Wrote:  It doesn't work, it seems that you have to define all of your variables at the start. This is not very practical. Is there a way that I can define new variables as I go. I'm not sure how many i will need.
Now I see why most people decide for other brands of calculators that are even slower. You dont have to be a programmer to write a simple program.
It works if you write it: R:= a+b+c;
The assignment syntax is := not =
Find all posts by this user
Quote this message in a reply
01-25-2021, 04:38 PM
Post: #7
RE: input issues
Thanks it works, But if I write like Sx:= It throws an error. But okay.

How will make the program run the DMS command like if my Variable O= 0.12312412409321
to make it display in Degrees minutes seconds?
Find all posts by this user
Quote this message in a reply
01-25-2021, 05:00 PM
Post: #8
RE: input issues
(01-25-2021 04:38 PM)Amer7 Wrote:  Thanks it works, But if I write like Sx:= It throws an error. But okay.
On the Prime only the variables A to Z are predefined global variables. Any other variable need to be defined before using it.

(01-25-2021 04:38 PM)Amer7 Wrote:  How will make the program run the DMS command like if my Variable O= 0.12312412409321
to make it display in Degrees minutes seconds?
The function for that on the Prime is →HMS, so you can do →HMS(O)
Find all posts by this user
Quote this message in a reply
01-25-2021, 06:25 PM (This post was last modified: 01-25-2021 06:31 PM by Amer7.)
Post: #9
RE: input issues
Can someone tell me why the program is returning a=0, b=0; when if we input
Input σ₁²: 2.45377

Input σ₂²: 0.000838
Input σ₁₂: −0.027712
Input F(α,2,f): 2.865


Code:
EXPORT Elipsa1()
BEGIN
LOCAL a1,b1,b2,f,r;
INPUT({a1,b2,b1,f},"Input test", {"Input σ₁²","Input σ₂²","Input σ₁₂","Input F(α,2,f)"});
 PRINT({a1,b2,b1,f});
LOCAL a,b,a3,b3,a4,b4,s1,s2;
 r:=SQRT((a1-b2)^(2)+4*b1^(2));
LOCAL K,L;
 L=((a1+b2+r)/(2)); /// LAMBDA 1
 K=ABS(((a1+b2-r)/(2)));   /// Lambda 2
 a=SQRT(L);
 b=SQRT(K);
 a3=SQRT(5.991*L);
 b3=SQRT(5.991*K);
 s1=SQRT(a1);
 s2=SQRT(b2);
 P:=((b1)/(SQRT(a1)*SQRT(b2)));
 O:=ATAN(((L-a1)/(b1)));
 IF O<0 THEN
 U:=O+180;
 ELSE
 U=O;
 END;
 PRINT({"R="+r});
 PRINT({"L1="+L});
 PRINT({"L2="+K});
 PRINT({"a="+a});
 PRINT({"b="+b});
 PRINT({"Sx="+s1});
 PRINT({"Sy="+s2});
 PRINT({"P="+P});
 PRINT({"O="+→HMS(U)});
PRINT("95% elipsa kad imamo prekobrojnost");
PRINT({"F="+f});
PRINT({"a="+a4});
PRINT({"b="+b4});
PRINT({"O="+→HMS(U)});
END;

This is a program for calculating Elliptical mistakes
And can someone explain why when I try to add may variables to one LOCAL like
LOCAL a,b,c,d,e,f,g,h,e,i2,r3,r2 I get a Syntax error ? And i have to like redistribute it to a new row?
Find all posts by this user
Quote this message in a reply
01-25-2021, 07:13 PM (This post was last modified: 01-25-2021 07:13 PM by C.Ret.)
Post: #10
RE: input issues
(01-25-2021 06:25 PM)Amer7 Wrote:  And can someone explain why when I try to add many variables to one LOCAL like
LOCAL a,b,c,d,e,f,g,h,e,i2,r3,r2 I get a Syntax error ? And i have to like redistribute it to a new row?

Put the cursor on LOCAL and press the [(?) Help] black button of your HP Prime and you will read that the number of local variable per LOCAL instruction is limited to height and no more.

A 'Syntax Error' will point out this and stop after the 8th variable name in your code.

Smile
Find all posts by this user
Quote this message in a reply
01-25-2021, 07:32 PM (This post was last modified: 01-25-2021 07:33 PM by Didier Lachieze.)
Post: #11
RE: input issues
(01-25-2021 06:25 PM)Amer7 Wrote:  Can someone tell me why the program is returning a=0, b=0;

As I said previously assignments should be done with :=, not with =.
So you should replace L=(, K=ABS... by L:=(, K:=ABS etc...

When you write a=b the Prime is evaluating if a is equal to b, not assigning b to a.
Find all posts by this user
Quote this message in a reply
01-25-2021, 07:36 PM (This post was last modified: 01-25-2021 08:02 PM by C.Ret.)
Post: #12
RE: input issues
(01-25-2021 06:25 PM)Amer7 Wrote:  Can someone tell me why the program is returning a=0, b=0; when if we input
Input σ₁²: 2.45377
Input σ₂²: 0.000838
Input σ₁₂: −0.027712
Input F(α,2,f): 2.865

All the lines you entered in your code after LOCAL K,L; are erroneous.
The equal sign you use is reserved for equation, to affect value to variables, the correct syntax is to use the affectation sign ':=' or the store sign '▶ '

For example: a:=2; 3▶b;

An expression like
a=3;
is evaluated as an equation and the returned value of this evaluation is lost since there no affectation nor print or return order.

That why you a and b variable stay at 0, they are never the subject to any affectation or storing.


Here, as an example, is the way I would have compose your application:
Code:
EXPORT Elipsa1()
// This is a program for calculating Elliptical mistakes  
BEGIN
LOCAL a1,b1,b2,f;
INPUT({a1,b2,b1,f},"Input test", {"Input σ₁²","Input σ₂²","Input σ₁₂","Input F(α,2,f)"});
LOCAL  r:=SQRT((a1-b2)^2+4*b1^2);
       L:=((a1+b2+r)/2);         // Lambda 1 in GLOBAL real variable L
       K:=ABS((a1+b2-r)/2);      // Lambda 2 in GLOBAL real varialbe K
LOCAL  a:=SQRT(L);
LOCAL  b:=SQRT(K);
LOCAL a3:=SQRT(5.991*L);
LOCAL b3:=SQRT(5.991*K);
LOCAL s1:=SQRT(a1);
LOCAL s2:=SQRT(b2);
       P:=(b1/(SQRT(a1)*SQRT(b2)));     // GLOBAL real variable P
       O:=ATAN((L-a1)/b1);              // GLOBAL real variable O
 IF O<0 THEN U:=O+180 ELSE U=O END;     // GLOBAL real variable U
PRINT();                                // CLEAR TEXT EDITOR PAGE
 PRINT({a1,b2,b1,f});
 PRINT(" R="+r);
 PRINT("L1="+L);
 PRINT("L2="+K);
 PRINT(" a="+a);
 PRINT(" b="+b);
 PRINT("Sx="+s1);
 PRINT("Sy="+s2);
 PRINT(" P="+P);
 PRINT(" O="+ →HMS(U) );
 PRINT("95% elipsa kad imamo prekobrojnost");
 PRINT({" F="+f});
// PRINT(" a="+a4);               // <-- definition of a4 and b4 missing ??
// PRINT(" b="+b4);
// PRINT(" O="+ →HMS(U) );
END;

Since no LOCAL instruction were used for K l P O U, values are store in the corresponding user real variable you can acces with [Vars]/HOME/Real/...
Find all posts by this user
Quote this message in a reply
01-25-2021, 07:42 PM
Post: #13
RE: input issues
(01-25-2021 07:32 PM)Didier Lachieze Wrote:  
(01-25-2021 06:25 PM)Amer7 Wrote:  Can someone tell me why the program is returning a=0, b=0;

As I said previously assignments should be done with :=, not with =.
So you should replace L=(, K=ABS... by L:=(, K:=ABS etc...

When you write a=b the Prime is evaluating if a is equal to b, not assigning b to a.

aaaaa, I understand now, i thought that local was the same like in java
int a,b,c,d ;
and when i say int a=0; it assigns 0 to a.
Now I understand that I can say:
Local a1,a2,a3,
a1:=a2+a3;
Thanks, it's getting better.
Find all posts by this user
Quote this message in a reply
01-25-2021, 08:00 PM (This post was last modified: 01-25-2021 08:15 PM by Amer7.)
Post: #14
RE: input issues
Now i'm facing another issue

Code:
IF O<0 THEN
 U:=O+180;
 ELSE
 U=O;
 END;
When i use +180 it adds it to the O
but when I use +π // pi it doesn't want to add it to O

Btw: Finished and working, thanks to all of your help.
( Program za racunanje Gresaka elipse HP prime)

I hope it's not hard to make it launch like an App.


Attached File(s)
.hpprgm  Elipsa1.hpprgm (Size: 3.03 KB / Downloads: 3)
Find all posts by this user
Quote this message in a reply
01-26-2021, 03:01 PM (This post was last modified: 01-26-2021 04:29 PM by Amer7.)
Post: #15
RE: input issues
How can I make a Matrix like nxm size and then fill the places with my own variables, then to operations between 2 Matrices and print them out. I went with Help but when I try it like this;
Code:
LOCAL A1,A2; /// A1=B, A2=Cl
A1:=MAKEMAT(0,2,2)→[[b11,b12],[b21,b22]];
A2:=MAKEMAT(0,2,2)→[[c11,c12],[c21,c22]];

It throws an error in this field "→" Is there another symbol that i can use in notepad when writing programs?

Will it function as a matrix if I write it like this:
Code:
LOCAL A1,A2; /// A1=B, A2=Cl
A1:=[[b11,b12],[b21,b22]];
A2:=[[c11,c12],[c21,c22]];
[/code]

It seems it works also you can print by row
PRINT=(""+A1(1)); - Prints first row of matrice A1

EDIT: How will I extract value from matrix A2 that is a product of A2:=A1*A2 ?
I need values of A2 [a11,a12], [a21,22] etc...
Find all posts by this user
Quote this message in a reply
01-26-2021, 04:34 PM (This post was last modified: 01-26-2021 04:35 PM by toml_12953.)
Post: #16
RE: input issues
(01-25-2021 07:42 PM)Amer7 Wrote:  
(01-25-2021 07:32 PM)Didier Lachieze Wrote:  As I said previously assignments should be done with :=, not with =.
So you should replace L=(, K=ABS... by L:=(, K:=ABS etc...

When you write a=b the Prime is evaluating if a is equal to b, not assigning b to a.

aaaaa, I understand now, i thought that local was the same like in java
int a,b,c,d ;
and when i say int a=0; it assigns 0 to a.
Now I understand that I can say:
Local a1,a2,a3,
a1:=a2+a3;
Thanks, it's getting better.

You can also combine LOCAL with assignment

LOCAL bx:=7, c:=12;

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
01-27-2021, 11:45 AM (This post was last modified: 01-27-2021 01:13 PM by Amer7.)
Post: #17
RE: input issues
How do I enable an angle value in Deg, min, sec to be inputted into a program?
When I use ;
Code:
LOCAL a,d,sa,sd;
INPUT({a,d,sa,sd},"Input test", {"Directional angle","lenght A-B","S ugla(sec)","s lenght"});
It doesnt let me input the angle, if I press a b/c to inport the angle as a fraction I get Bad argument type.

Also I'm having an issue printing Matrices row by row for easier viewing.

Lets supose my matrix is 2x2 = B
PRINT (B(1)); - should print first row
PRINT (B(2)); - should print second row but i get a Sytax eror.

Code:
EXPORT Direkcioni()
BEGIN
LOCAL a,d,sa,sd;
INPUT({a,d,sa,sd},"Input test", {"Direkcioni ugao","Duzina A-B","S ugla(sec)","s duzine"});
LOCAL b11,b12,b21,b22; /// MAT B
b11:=COS(a);
b12:=-(d*SIN(a));
b21:=SIN(a);
b22:=(d*COS(a));
B:=[[b11,b12],[b21,b22]];
LOCAL c1,c2; /// MAT Cl
c1:=sd^2;
c2:=(sa/(206264.8^2));
C:=CAS.diag({c1,c2});

LOCAL Cx,p,sx,sy; ///MAT Cx

Cx:=B*C*TRN(B);
p:=(Cx(1,2))/(SQRT(Cx(1,1)*Cx(2,2)));
sx:=SQRT(Cx(1,1));
sy:=SQRT(Cx(2,2));

/// RACUNANJE R

LOCAL R,l1,l2;    ///=lambda 1, l2=lambda 2, R=R
R:=SQRT(((Cx(1,2)+Cx(2,2))^2)+4*((Cx(1,2))^2));
l1:=(0.5*(Cx(1,1)+Cx(2,2)+R));
l2:=(0.5*(Cx(1,1)+Cx(2,2)-R));

/// RACUNANJE UGLA O
LOCAL O1;
O=ATAN((l1-Cx(1,1))/(Cx(1,2)));
IF O<0 THEN
O1:=O+180;
ELSE
O1:=O;
END;

/// RACUNANJE A i B
A:=SQRT(l1);
B:=SQRT(l2);

/// ISPIS

PRINT({"O="+→HMS(O1)});
PRINT("_____________");
PRINT ("MATRICA B");
PRINT (B);
PRINT (B);
PRINT("________________");
PRINT ("MATRICA Cl");
PRINT (C);
PRINT (C);
PRINT("_____________");
PRINT ("MATRICA Cx");
PRINT (Cx);
PRINT (Cx);
PRINT("_____________");
PRINT("P="+p);
PRINT("A="+A);
PRINT("B="+B);

END;
   
Find all posts by this user
Quote this message in a reply
01-27-2021, 01:59 PM (This post was last modified: 01-27-2021 02:01 PM by Didier Lachieze.)
Post: #18
RE: input issues
(01-27-2021 11:45 AM)Amer7 Wrote:  How do I enable an angle value in Deg, min, sec to be inputted into a program?
When I use ;
Code:
LOCAL a,d,sa,sd;
INPUT({a,d,sa,sd},"Input test", {"Directional angle","lenght A-B","S ugla(sec)","s lenght"});
It doesnt let me input the angle, if I press a b/c to inport the angle as a fraction I get Bad argument type.

To enter an angle value in Deg, min, sec you need to press [Shift] [a b/c] after each value, for example to enter 25 deg 46 min 7 sec press:
25 [Shift][a b/c] 46 [Shift][a b/c] 7 [Shift][a b/c]
and you'll get: 25°46′7″

(01-27-2021 11:45 AM)Amer7 Wrote:  Also I'm having an issue printing Matrices row by row for easier viewing.

Lets supose my matrix is 2x2 = B
PRINT (B(1)); - should print first row
PRINT (B(2)); - should print second row but i get a Sytax eror.

You cannot use B or C as global matrix variables, these are defined as global real variables as you can check with Vars>Home>Reals.
If you want a global matrix variable you can use M0...M9 (available in Vars>Home>Matrix), or you can use a local variable such as the Cx variable in your program.
Find all posts by this user
Quote this message in a reply
Post Reply 




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