cancel
Showing results for 
Search instead for 
Did you mean: 
sideshot
Level 1
15 11 0 0
Message 1 of 5
939
Flag Post

Solved!

HELP with Programming flow; REPEAT, CHOOSE, subroutines?

HP Recommended
HP Prime

Here's a sample of my program below. I like the individuality of accessing each program independently, but programs 2&3 are dependent on variables defined in program1...at the front end, Prog1 is essential, then i'd move on to Prog2 or 3 depending on my needs. How can code my prog1 at the back end, to give the option to move on to prog2, prog3, or exit? Additionaly, when ending in either prog2 or 3, how to choose to repeat that specific program until exiting?

 

I expect to use each program individually, but want the option to continue or exit; i don't like having to exit in order to start one of the other programs all over agin.

 

EXPORT Prog1()

BEGIN

(program body)

 

(before ending, would like an option to run prog2, prog3, or exit)

END;

 

EXPORT Prog2()

BEGIN

(program body)

 

(before ending, would like an option to run prog2, prog3, or exit)

END;

 

EXPORT Prog3()

BEGIN

(program body)

 

(before ending, would like an option to run prog2, prog3, or exit)

END;

0 Kudos
4 REPLIES 4
Maké
Level 9
3,551 3,490 180 541
Message 2 of 5
Flag Post
HP Recommended

Hi!, @sideshot:

 

Try, with ...

http://edspi31415.blogspot.com.ar/2013/11/hp-prime-programming-tutorial-3-while.html

 

http://edspi31415.blogspot.com.ar/search?q=CHOOSE

Kind Regards !.
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
0 Kudos
sideshot
Author
Level 1
15 11 0 0
Message 3 of 5
Flag Post
HP Recommended
Eddies example isn’t clear enough for me. It would be better for me to understand if someone redlined my example. Where would I use/place REPEAT, or WHILE, or ??? Would I use WHILE or REPEAT & CHOOSE?? I’m not exactly a pro, but I’m advancing.
0 Kudos
Jan_D
Level 6
305 297 32 76
Message 4 of 5
Flag Post
HP Recommended

Hello Sideshot,

 

In my opinion you do not need REPEAT or WHILE, but CHOOSE is a good idea.

 

Because the programs call each other you have to declare them at the beginning.

 

This program seems to do what you want:

 

prog1();
prog2();
prog3(); //declarations of prog1, prog2, prog3 at the beginning.


EXPORT prog1()
BEGIN
LOCAL x;
MSGBOX("This is prog1, please press OK");
CHOOSE(x,"Choose an option","prog1","prog2","prog3","exit");
IF x=1 THEN prog1() END;
IF x=2 THEN prog2() END;
IF x=3 THEN prog3() END;
END;

EXPORT prog2()
BEGIN
LOCAL x;
MSGBOX("This is prog2, please press OK");
CHOOSE(x,"Choose an option","prog1","prog2","prog3","exit");
IF x=1 THEN prog1() END;
IF x=2 THEN prog2() END;
IF x=3 THEN prog3() END;
END;

EXPORT prog3()
BEGIN
LOCAL x;
MSGBOX("This is prog3, please press OK");
CHOOSE(x,"Choose an option","prog1","prog2","prog3","exit");
IF x=1 THEN prog1() END;
IF x=2 THEN prog2() END;
IF x=3 THEN prog3() END;
END;


 

See also this valuable information:

 

http://www.hpmuseum.org/forum/thread-216.html

http://www.hpmuseum.org/forum/thread-215.html

Tags (1)
sideshot
Author
Level 1
15 11 0 0
Message 5 of 5
Flag Post
HP Recommended
YES!! Perfect. That worked brilliantly! Thanks so much!
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