cancel
Showing results for 
Search instead for 
Did you mean: 
vitor3
New member
3 2 0 0
Message 1 of 9
2,367
Flag Post

[HP PRIME] multiple INPUTS (user defines the quantity)

HP Recommended
HP Prime

Hello everyone,

 

I'm in trouble to find a way to display all the INPUTs the user request. I manage to do that only showing one per time. What command should I use to display ex: P1, P2 and P3 all together in the same screen and same time?  

 

Ps.: nevermind the excess of variables, that's just a part of a code

 

Any advice is welcome! 

 

EXPORT Mason_Gain_Formula()

BEGIN
LOCAL num_paths, num_loops, P, Px, L, Lx, Δx, Δ;
LOCAL p, l, x;

//-- display position ---
LOCAL h1, h2;
h1 := {8,22,0};
h2 := {0,0,1};
Px := {};
Lx := {};
Δx := {};


INPUT({{num_paths,[3]},{num_loops,[3]}}, 
"Mason's Gain Formula",  
{" Paths = ", " Loops = "}, 
{" Quantity of direct paths"," Quantity of closed loops"}); 

FOR p FROM 1 TO num_paths DO  
 INPUT({{P,[3],h1}}, 
 "Mason's Gain Formula",  
 {" P"+p}, 
 {" Path number "+p});
 Px(p):= P;
 P:=0;
 h1:= h1+h2;

END;

RETURN(Px);
END;

 

0 Kudos
8 REPLIES 8
Tim_Wessman
Level 8
Level 8
747 744 121 187
Message 2 of 9
Flag Post
HP Recommended

Very close! Just add more lists into your first parameter, and an equal number for your labeles and helps.

 

EXPORT InformTest()
BEGIN
local a,b,c;
INPUT({{a,[3]},{b,[3]},{c,[3]}},
 "Mason's Gain Formula",  
 {" P"+1,"P"+2, "P"+3},
 {" Path number "+1, "Path number "+2, "Path number "+3});
END;

TW

Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.
0 Kudos
vitor3
Author
New member
3 2 0 0
Message 3 of 9
Flag Post
HP Recommended

Hey Tim, thanks for the reply!

 

Maybe I didn't make myself clear, but what I am aiming with this code is to have a variable number of INPUTs, i.e. it should not be fixed. The number of paths should be entered by the user.

 

The actual problem here is that the code is not showing all INPUTs alltogether. 

 

P1.pngp2.pngp3.png

0 Kudos
Jan_D
Level 6
305 297 32 76
Message 4 of 9
Flag Post
HP Recommended

 

Why do not you accept lists as input?

That is much easier.

 

So write eg a program which has list as an argument:

myprogram(list)

 

or, within a program:

INPUT({{list,[6]}})

 

For list you could enter an explicit list, or prepare the list in the Lists Catalog, and enter for instance: L1.   

0 Kudos
Jan_D
Level 6
305 297 32 76
Message 5 of 9
Flag Post
HP Recommended

Without the use of lists this is the best I can do:

 

2017-09-04 13.34.37.jpg

 

It offers the possibility to specify the number of entries which are used, and there are 50 entries, over 8 pages.

 

Specifying this number is necessary because otherwise it would not be clear if a zero would be an input or just a default value.

 

This is the program:

 

2017-09-04 13.38.03.jpg

 

 

I created the long list: a(1),a(2),..... with another program which returned a string containing these 50 elements, I copied the string into the Program Editor, and removed the quotes.

0 Kudos
Tim_Wessman
Level 8
Level 8
747 744 121 187
Message 6 of 9
Flag Post
HP Recommended

So I was copletely convinced this would be possible, but even trying all sort of tricks I've been unable to get things working. I've put this on our list to investigate because it should definitely be possible.

TW

Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.
0 Kudos
vitor3
Author
New member
3 2 0 0
Message 7 of 9
Flag Post
HP Recommended
Yeah... that's exactly how I feel! It must have a way out! Also tried others things but no progress. The code is operational, but not sophisticated as it could.

Anyway, I'm glad it will be taken in consideration sometime.

Thanks for the help
0 Kudos
OndrejPopp
New member
1 1 0 0
Message 8 of 9
Flag Post
HP Recommended

Ok, in the meantime you can do this,

EXPORT inputTest ()

BEGIN

 LOCAL s := 

  "LOCAL l,m;" +

  "IFTE (

     INPUT ({l,m}),

     {l,m},

     {});";

 

  RETURN EXPR (s);

END;

 

In other words, you can encode such a menu in a text string, and evaluate it with EXPR. This is kind of similar with the previous post from Jan_D https://h30434.www3.hp.com/t5/user/viewprofilepage/user-id/2813760, mentioning the 50 auto generated and pasted entries, but this one fits exactly without the need of copy/paste of auto generated content.

 

0 Kudos
Jan_D
Level 6
305 297 32 76
Message 9 of 9
Flag Post
HP Recommended

Good idea to use the EXPR command.

Your program does not do what it should for me though.

 

I suggest this program:

 

EXPORT inputtest2(n)
BEGIN
local a,k,c,s;
a:={};
s:="";
a(n):=0; //creates n list elements
FOR k FROM 1 TO n DO
c:="a(" +k +")";  // c="a(k)"
s:=s+c+",";        //s="a(1),a(2),...a(n),"
END;

s:=LEFT(s,SIZE(s)-1);  //removes last comma

//we want this: INPUT({a(1),a(2),...a(n)});
EXPR("INPUT({" +s+ "})");
RETURN a;
END;

Here n is the number of entries we want.

 

For n=4 we get:

 

pic2.png

0 Kudos
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation