HP Forums
HP Prime: run a program in another program - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: HP Prime: run a program in another program (/thread-255565.html)



HP Prime: run a program in another program - Davi Ribeiro de Oliveira - 11-11-2013

Hello friends:

I have a program that asks 5 external variables and call the grid. A second program has 8 external variables to call gutter. I need this second program run first, adding the result with their external variables. Which command need to include for the program run Trough the grid, without me having to run before the Grid program? Because that's what's happening. I have to run before the Grid program, and then run the program.

Can someone help me?

Thank You

David


Re: HP Prime: run a program in another program - Joseph Ec - 11-11-2013

Hi Friend,


May be you can use the powerfull commad EXPR.

Example: I have a choose command to select what program to run then execute the program.


//programs definition

PROGRAM2();

PROGRAM3();

...

EXTERNAL PROGRAM1

BEGIN

IF CHOOSE(option,... PROGRAMS LIST... ) THEN

EXPR("PROGRAM"+option+"()"); // will execute PROGRAM2 OR 3 ...

END;

END;

In the PROGRAMx you can create a list to return values to use in the rest of PROGRAM1.

Hope these help You, Best regards!!

jose


Re: HP Prime: run a program in another program - Han - 11-11-2013

Quote:
Hi Friend,

May be you can use the powerfull commad EXPR.

Example: I have a choose command to select what program to run then execute the program.


//programs definition

PROGRAM2();

PROGRAM3();

...

EXTERNAL PROGRAM1

BEGIN

IF CHOOSE(option,... PROGRAMS LIST... ) THEN

EXPR("PROGRAM"+option+"()"); // will execute PROGRAM2 OR 3 ...

END;

END;

In the PROGRAMx you can create a list to return values to use in the rest of PROGRAM1.

Hope these help You, Best regards!!

jose


Another method:

EXPORT PROGRAM1()
BEGIN
… source code for program 1 …
END;

EXPORT PROGRAM2()
BEGIN
… source code for program 2 …
PROGRAM1(); // run program 1 as the last thing to do inside program 2
END;

This works for any number of programs. All you need to do is make sure to EXPORT each program you wish to use within other programs. They need not be within one source file, either.

Edited: 11 Nov 2013, 7:46 p.m.


Re: HP Prime: run a program in another program - Michael de Estrada - 11-11-2013

The only problem with this approach is that all the called exported programs will annoyingly appear in the main Toolbox User Program Functions list, unless you group them under a separate main program name. What would be really helpful would be some sort of main program declaration, which could call subroutines that would not appear as global programs or functions.


Re: HP Prime: run a program in another program - Tim Wessman - 11-11-2013

PROGRAM1()
BEGIN
… source code for program 1 …
END;

EXPORT PROGRAM2()
BEGIN
… source code for program 2
PROGRAM1(); // run program 1 as the last thing to do inside program 2
END;

Fixed! Magic! :-)

TW




Re: HP Prime: run a program in another program - Davi Ribeiro de Oliveira - 11-11-2013

Ok, my friends:

I will follow all these guidelines to view the result.

Thank You

David


Re: HP Prime: run a program in another program - Michael de Estrada - 11-11-2013

Syntax error !

Edit. I forgot that the called program(s) need to be placed before the calling program, because this is not a compiler. Works good now.

Edited: 11 Nov 2013, 9:09 p.m.