Post Reply 
Modular programming?
03-10-2019, 01:57 AM
Post: #1
Modular programming?
Apologies for the newbie question. I've had the original Prime since almost day one of its availability. There were a number of initial reasons it never got much use, with the main one being very hard to see key labels (light blue on grey), and secondly, the lack of integration of its RPN stack with programs. There were other reasons, but those were the two main ones.

Recently, I almost ordered a Prime G2, mainly to get the new higher-contrast keyboard, and to give it another go since the Prime is, after all, a very capable and impressive machine overall. In anticipation, I sat down with the old Prime again to refresh my memory and figure what I could do with the programming, grudgingly ignoring the lack of stack manipulation capability. I decided I would create a few new "Apps" in order to try and organize program modules into logical groups and avoid cluttering up the program list menu. Much to my surprise, it seems that programs created are not local to an app at all, rather they are all global and visible the same way in the program menu for each App?

I learned programming with Modula-2 back in the day (mid 80's) and that has influenced me to thus always structure my software in very logical, organized blocks of routines, with each module throughly debugged and documented before integrating with others. My HP-50G allowed for a very structured approach, with its directories (which I know were "fake" and simulated but still very helpful) and the ability to essentially hide utility routines by manually organizing directories in such a way so that completed and fully debugged modules are further pages away from the first directory screen, and thus not distracting and in the way, so to speak. Not sure if I described that very well but hopefully you get the idea of what I meant?

A simple question then: is something even remotely like that possible for the Prime? I know there are no directories, real or simulated, but is there no way to group globally accessible utility functions into an App, for example, so that they do not clutter up the program menu everywhere? If I recall, it is possible to somehow compile or package an app on the Prime (not that I've explored that yet, and I may be wrong) and if one does that, are the functions then somehow hidden, yet still accessible to normal global programs, as long as they are exported of course, similar to built-in functions? If so, then I definitely need to look into that feature!

Also, I presume there is actually no way of manually sorting the list of programs, and the only options are chronologically or alphabetically? The only way I can see having control over program module positions in the list is to sort them alphabetically and name the utility routine modules starting with a 'Z' for example, to force them to the end of the list of programs. I suppose that might suffice for my needs, if there is no other way.

I do appreciate any hints or pointers to other threads where this might have been discussed. If anyone feels that a simple thread search should turn up the info I need, or that I should RTFM, then please feel free to say that; I won't take any offence. I honestly did not spend a ton of time looking through this forum, nor the documentation and tutorials thread and the main reason for that is that I somehow expect to be disappointed that what I am seeking to do is simply not possible, so the answer might be a swift "no" to my query!
Find all posts by this user
Quote this message in a reply
03-10-2019, 05:42 PM
Post: #2
RE: Modular programming?
Yes, what you're asking can be done.

Before going any further, make sure your Prime is updated to the latest version, which is 14181 (2018 10 16), I think.

You then start by creating an app either derived from one of the baked-in apps or inheriting nothing at all. Let's say you call that app "MyFuncs" for argument's sake.

The programs in MyFuncs won't clutter up your list of programs but if they are "exported" (check out the EXPORT keyword) then they are accessible from any app by qualifying them: MyFuncs.ProgName()
Find all posts by this user
Quote this message in a reply
03-11-2019, 04:36 AM
Post: #3
RE: Modular programming?
Thanks grsbanks for those tips. I thought I had tried exactly that, but if there was a somewhat recent firmware update that enabled that, then I very well might not have the Prime up-to-date enough.

I will pursue exactly what you have suggested. Thank you very much for the guidance!
Find all posts by this user
Quote this message in a reply
03-11-2019, 06:47 PM
Post: #4
RE: Modular programming?
Bonjour

La creation d'une application dédiée pour des fonctions utilisateur pouvant être appelées par d'autres applications ou programmes est une bonne idée je pense.
Mais nous ne pouvant pas savoir si une application est présente ou pas contrairement à un programme.
Ce qui en limite l'intéret je trouve.

Hello

Creating a dedicated application for user functions that can be called by other applications or programs is a good idea, I think.
But we can not know if an application is present or not unlike a program.
What limits the interest I find.

Sorry for my english
Find all posts by this user
Quote this message in a reply
03-14-2019, 03:19 AM (This post was last modified: 03-14-2019 03:21 AM by mgmander.)
Post: #5
RE: Modular programming?
(03-10-2019 05:42 PM)grsbanks Wrote:  Yes, what you're asking can be done.

Before going any further, make sure your Prime is updated to the latest version, which is 14181 (2018 10 16), I think.

You then start by creating an app either derived from one of the baked-in apps or inheriting nothing at all. Let's say you call that app "MyFuncs" for argument's sake.

The programs in MyFuncs won't clutter up your list of programs but if they are "exported" (check out the EXPORT keyword) then they are accessible from any app by qualifying them: MyFuncs.ProgName()

Well, it turns out I did not ask my question properly or clearly enough, and in the end I was barking up the wrong tree anyway I suspect.

I was referring to programming on the Prime itself, and in the listing you get when you select "Shift-Program", I am getting all programs in all apps, and was wondering if there was some way of having programs that are only local to the currently selected app, and then only show when that app is the current one. For example, say I create a "Utilities" app that has some programs with general use functions that I might use in all programs. I was hoping that the program that defines and exports those functions might only show in said program listing when "Utilities" was the current app, but not show in the program list when a different app in the calculator was selected.

I did update my firmware, and in the process starting digging around the Connectivity Kit, and now see that one has the ability to edit one app-specific program, with functions that get called automatically when the app is started, and when various specific keys are pressed: Symb, Plot, Num etc. In the end, that is going to be far more useful for me I think.

That said, I would appear that there is no way of editing that app program shell on the calculator itself, unless I am missing something? So any work there needs to be done with the Connectivity Kit? I also presume there is only the one program that is linked with the app and that all code, at least code you want hidden from the general program menu, needs to reside there?

Anyway, before I ask any more questions, I am going to have to mull over how I can make that system work for me to keep things organized the way I want to. I actually think it will be fine in the end, except for the limitation of not being able to work on things in the field with only the Prime. I suppose I can edit and debug routines using the regular "global" program list, then when they're done, transfer the code into the app-specific program with the Connectivity Kit...

Anyway, lots to think about. Thanks for giving me the nudge in any case!
Find all posts by this user
Quote this message in a reply
03-14-2019, 03:57 AM
Post: #6
RE: Modular programming?
The top item in the "program" catalog is the program file for you currently active application.

So yes, you can edit it directly.

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
03-14-2019, 04:22 AM
Post: #7
RE: Modular programming?
(03-14-2019 03:57 AM)Tim Wessman Wrote:  The top item in the "program" catalog is the program file for you currently active application.

So yes, you can edit it directly.

Oh good grief. Thanks for that wee bit of advice which really should have been terribly obvious. Now where is that "embarrassed" emoticon? (Rhetorical question!) I'll stop asking stupid noob questions now and quit wasting people's time.

Maybe I will endeavour to order a Prime G2 after all. The higher contrast keyboard will probably make it way easier and more appealing to work with for me, so I'll be more likely to play with and explore the device itself, hopefully learning as I go!
Find all posts by this user
Quote this message in a reply
03-14-2019, 09:14 AM
Post: #8
RE: Modular programming?
(03-14-2019 04:22 AM)mgmander Wrote:  Oh good grief. Thanks for that wee bit of advice which really should have been terribly obvious. Now where is that "embarrassed" emoticon? (Rhetorical question!) I'll stop asking stupid noob questions now and quit wasting people's time.

Every one of us here was a n00b at some stage. We've all been there, done that, got the T-shirt etc.

(03-14-2019 04:22 AM)mgmander Wrote:  Maybe I will endeavour to order a Prime G2 after all. The higher contrast keyboard will probably make it way easier and more appealing to work with for me, so I'll be more likely to play with and explore the device itself, hopefully learning as I go!

The difference between the two is dramatic. However, I still find it infinitely less frustrating to develop on the Virtual Prime using a real keyboard.
Find all posts by this user
Quote this message in a reply
03-16-2019, 11:44 AM
Post: #9
RE: Modular programming?
I suggest that you download some programs and study successful approaches taken by others. For example, I use the SVD of matrices a lot. I downloaded SVD2 for my purpose. I discovered that it also taught me a lot about programming, in particular about subroutines and local versus global entries.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)