HP Forums

Full Version: HP Prime: run a program in another program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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

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

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.

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.

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

Ok, my friends:

I will follow all these guidelines to view the result.

Thank You

David

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.