HP Forums
Automatically generating program from a template. - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Automatically generating program from a template. (/thread-2869.html)



Automatically generating program from a template. - John P - 01-17-2015 04:18 AM

Hello,

Automatically generating program from a template.
Is it at all possible to automatically generate program from a template. Lets say, I want to make some kind of library for functions or for doing something on sets of equations. For the template it would require to do some "staff" and this would be the same repetitious task for all entries in the library.
I do not now if it is at all possible to write a program on HP Prime using some input parameters and the given template already present on HP Prime. The program written on HP Prime would have to do some "staff" on a copy of the template and then rename the copy of the template and store it as a user program to show it in the "User Catalog" under some library name. Thank you.

Cheers


RE: Automatically generating program from a template. - Han - 01-17-2015 04:20 AM

You can using the Programs() command. You can use it to create a new program from a string.


RE: Automatically generating program from a template. - John P - 01-17-2015 06:44 AM

Hello Han,

Yes, it works. Exactly what I needed. Thanks.

Cheers


RE: Automatically generating program from a template. - bobkrohn - 01-18-2015 03:34 AM

Where is that documented?
I saw something on the Forum about Programs() but thought it just made a List of Program Names.
Don't see it in the User Guide.


RE: Automatically generating program from a template. - Didier Lachieze - 01-18-2015 04:43 AM

It is documented in the HP Prime Help: type "Programs" and press Help.

[Image: 1d0in.png]


RE: Automatically generating program from a template. - eried - 01-18-2015 05:45 AM

A little off topic, but how Programs and Notes aren't harmful functions like the "Flags" in the older hps? I mean I like having these functions but aren't they destroying the isolated-"App" concept?


RE: Automatically generating program from a template. - John P - 01-18-2015 07:04 AM

Hello,

I have problem with generating program to work the way I want.
To make things clear I want to make the distinction between generating an generated programs.
The generated program is the output from "Programs()" that I want in my "User Catalog". Everything is fine and the candidate for generated prgm. is a string that I can manipulate using "REPLACE" to do some changes to dummy placeholder substrings depending on what I want. The "REPLACE" replaces substring with another substring and that is OK too. The "Programs("name"):="string" spits out the program but then there is a problem because sometimes in the generated program I need to have string(s) preserved, when the generated prgm. is not a string anymore. What I do not know how to do is: how do I replace inside a string (future generated prgm.) something with another substring that will remain string after passing through "Programs()" or to put it differently: how to stick a substring inside a string that will stay string (when the generated prgm. is not a string anymore). I need that because inside the generated program, when it is in "User Catalog" ready to be used I need to do some processing that can only be done with strings because that is how CAS programs work in HP Prime, I think.

Cheers


RE: Automatically generating program from a template. - Marcus von Cube - 01-18-2015 09:53 AM

(01-18-2015 07:04 AM)John P Wrote:  how to stick a substring inside a string that will stay string (when the generated prgm. is not a string anymore).

You can use "" inside double quotes to represent a single ".


RE: Automatically generating program from a template. - Han - 01-18-2015 02:17 PM

Or use the string command. STRING("abc") -- this saves you from having to keep track of the double quotes.


RE: Automatically generating program from a template. - John P - 01-18-2015 02:48 PM

Hello,

I will try "STRING(abc)" or "STRING("abc")" later on. I can do what I want with the prgm. but I have to edit it manually when changing something inside. I wanted to do it automatically passing some parameters to generating prgm. to stick in the generated prgm. but as of today I do not know how.

Doing """ quote inside double quot or double quot inside double quot """" does nor work. Thanks.

Cheers


RE: Automatically generating program from a template. - John P - 01-19-2015 12:28 AM

(01-18-2015 02:17 PM)Han Wrote:  Or use the string command. STRING("abc") -- this saves you from having to keep track of the double quotes.

Hello,

Yes, it works like a charm with STRING(some_name). When the string for the generated prgm. passes through "Programs("name_for_the_prgm"):=string;" whatever is inside STRING(some_name) stays as a string so the generated program has no problems.

Cheers