50g group photo

Yahoo Groups archive

50g

Archive for 50g.

Index last updated: 2026-03-30 00:59 UTC

Thread

Can someone answer a question about program sub-routines

Can someone answer a question about program sub-routines

2009-07-04 by rickwendel763242

I'm aware that sub-routines are very useful. The thing I don't like is that the sub-routine is an object that must be stored in the same directory as the main program (I think). If its a big program you have a bunch of little programs to sort through to find the main program. Is their a way to tidy that up? Not to mention that you have to purge them all if you plan to use them with a CASE statement as objects to be evaluated - unless you can call the sub-routine in the form of a compiled local variable and CASE statement object which I haven't actually tried yet. (Compiled local variables automatically go away after program execution.) If their was a quick, neat way of doing all that it would be more useful than what I'm actually asking for help with. But, never-the-less I feel that what I'm about to describe would be useful anyway. That is, how do you write a small program (sub-routine) and copy and paste its contents into a larger one? I'm not talking about calling the name, I'm talking about copying the contents. How do you copy the contents of the small one and place it inside at a specific point in the larger program? Or, is their a way to just use the sub-routine name without having to keep 20 subs in the same directory with the main program?

Re: [50g] Can someone answer a question about program sub-routines

2009-07-05 by Don Hart

AFAIK, there's no way to do what you want. You can't have named procedures within one program, I don't think there's even a goto command. SysRPL or assembler may have named procedures but I don't know for sure.

What you can do is put the main program, subroutines and data all in one subdirectory. Subroutines that can be used by other programs can go into a higher level directory because, when it's called, the calc searches up the directory tree until it finds something by that name (same is true with data variables). So you can have several programs, each in their own directory, sharing a common subroutine.

You can use the ORDER command to put your main program in the 1st group in the soft menu.

I don't understand why you think you have to delete the subroutines when using the CASE construct. And you can delete subroutines just like data from within a program using the PURGE command, if you really need to.

Of course, if the subroutines aren't too long and aren't called too many times, you can just write the code inline in your main program. Self-modifying code is too messy and may end up using more memory, and that's assuming the operating system will allow it.


--- On Sat, 7/4/09, rickwendel763242 <rickwendel763242@...> wrote:

> From: rickwendel763242 <rickwendel763242@...>
> Subject: [50g] Can someone answer a question about program sub-routines
> To: 50g@yahoogroups.com
> Date: Saturday, July 4, 2009, 6:18 AM
> I'm aware that sub-routines are very
> useful.  The thing I don't like is that the sub-routine
> is an object that must be stored in the same directory as
> the main program (I think).  If its a big program you
> have a bunch of little programs to sort through to find the
> main program.  Is their a way to tidy that up? 
> Not to mention that you have to purge them all if you plan
> to use them with a CASE statement as objects to be evaluated
> - unless you can call the sub-routine in the form of a
> compiled local variable and CASE statement object which I
> haven't actually tried yet.  (Compiled local variables
> automatically go away after program execution.) If their was
> a quick, neat way of doing all that it would be more useful
> than what I'm actually asking for help with.  But,
> never-the-less I feel that what I'm about to describe would
> be useful anyway.  That is, how do you write a small
> program (sub-routine) and copy and paste its contents into a
> larger one?  I'm not talking about calling the name,
> I'm talking about copying the contents.  How do you
> copy the contents of the small one and place it inside at a
> specific point in the larger program?  Or, is their a
> way to just use the sub-routine name without having to keep
> 20 subs in the same directory with the main program?
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>     mailto:50g-fullfeatured@yahoogroups.com
>
>
>

Re: Can someone answer a question about program sub-routines

2009-07-05 by rickwendel763242

You're talking about subroutines and I'm talking about taking part of a program and pasting into another without using one. I didn't know that it looked for subroutines in the directory you're in, and then looked for them in directories above that one. So, they have it set up so that your subroutines can share the main programs directory and any above it. Wow, that's pretty ingenious and good to no. I would prefer to just use subroutines but it's kind of retarded having your programs look for them in directories above the current one. I can't store 20 subroutines in the same program directory as the main programs directory. So, can I put a directory on the first level and have all my subroutines found in that directory? That would make a little sense or do I have to use the ORDER command somehow to get it to find the special subroutine directory? I don't understand why you think that I think that I have to delete the subroutines when using the CASE construct. I've initialized the names used in a CHOOSE box with integers corresponding to the number of statements in the choose box so that I can direct each to a specific CASE number then at the end of the program I've PURGEd the names that got used as objects in CHOOSE box. That's the only way I could figure out how to get the CHOOSE box to go to a specific CASE number. I'm definitely not going to use that retarded INPUT statement to enter my data. You shouldn't have to PURGE any variables if you use compiled variables. I haven't tried doing that yet, have you? So evidentially you've never heard of anyone being able to cut and paste parts of a program into another. Is that true? I don't see how copying something could be classified as self-modifying a program. You can do it in any other programming language. It doesn't matter how long a subroutine is or how many times you call it into the main program. The only way that would be a problem is if your calculator is lacking memory and that can be remedied by simply getting an SD card formatted in FAT12 about 512K or so. I don't think the calculator can do much with anything above 512k to 1 Meg but I'm not totally for sure on that. Why are you so hung up on memory usage? Is someone going to spank you, if you use memory unwisely or something? I'm trying to write a stupid program that works. I don't care if Billy Bob at the CNC shop is psychotic or not and keeping a tally of unnecessary commands.

Re: [50g] Re: Can someone answer a question about program sub-routines

2009-07-06 by Don Hart

> You're talking about subroutines and I'm talking about taking part of a
> program and pasting into another without using one.

So you want to do the cut/paste while YOU are editing the program and not make the program do the cut/paste? Did you even try looking it up? See page 2-26 (page 80 in Adobe reader) of the 49g manual I uploaded at drop.io

> So, can I put a directory on the first level and have all my subroutines
> found in that directory?

Yes, as long as you make subdirectories off of that directory where your programs reside. Or you can use ORDER to make main program one of the first ones in the soft menu thus making it easier to find. The only thing ORDER does is rearrange the order of what you see in the soft menus. You do have soft menus turned on (set flag -117)?

> I don't understand why you think that I think that I have to delete the
> subroutines when using the CASE construct.

Because you said..
> Not to mention that you have to purge them all if you plan
> to use them with a CASE statement as objects to be evaluated...

I'm not following what you're doing with CHOOSE box & CASE. And I've never used a CHOOSE box, so someone else will have to chime in.

> It doesn't matter how long a subroutine is or how many times you call it
> into the main program. The only way that would be a problem is if your
> calculator is lacking memory...

One of the major reasons for using a subroutine is to prevent bloated code. But once you see how to do cut/paste, you can knock yourself out writing all the bloated code you want.

--- On Sun, 7/5/09, rickwendel763242 <rickwendel763242@...> wrote:

> From: rickwendel763242 <rickwendel763242@...>
> Subject: [50g] Re: Can someone answer a question about program sub-routines
> To: 50g@yahoogroups.com
> Date: Sunday, July 5, 2009, 12:42 AM
> You're talking about subroutines and
> I'm talking about taking part of a program and pasting into
> another without using one.  I didn't know that it
> looked for subroutines in the directory you're in, and then
> looked for them in directories above that one.  So,
> they have it set up so that your subroutines can share the
> main programs directory and any above it.  Wow, that's
> pretty ingenious and good to no.  I would prefer to
> just use subroutines but it's kind of retarded having your
> programs look for them in directories above the current
> one.  I can't store 20 subroutines in the same program
> directory as the main programs directory.  So, can I
> put a directory on the first level and have all my
> subroutines found in that directory? That would make a
> little sense or do I have to use the ORDER command somehow
> to get it to find the special subroutine directory?  I
> don't understand why you think that I think that I have to
> delete the subroutines when using the CASE construct. 
> I've initialized the names used in a CHOOSE box with
> integers corresponding to the number of statements in the
> choose box so that I can direct each to a specific CASE
> number then at the end of the program I've PURGEd the names
> that got used as objects in CHOOSE box.  That's the
> only way I could figure out how to get the CHOOSE box to go
> to a specific CASE number.  I'm definitely not going to
> use that retarded INPUT statement to enter my data. 
> You shouldn't have to PURGE any variables if you use
> compiled variables.  I haven't tried doing that yet,
> have you?  So evidentially you've never heard of anyone
> being able to cut and paste parts of a program into
> another.  Is that true?  I don't see how copying
> something could be classified as self-modifying a
> program.  You can do it in any other programming
> language.  It doesn't matter how long a subroutine is
> or how many times you call it into the main program. 
> The only way that would be a problem is if your calculator
> is lacking memory and that can be remedied by simply getting
> an SD card formatted in FAT12 about 512K or so.  I
> don't think the calculator can do much with anything above
> 512k to 1 Meg but I'm not totally for sure on that. 
> Why are you so hung up on memory usage?  Is someone
> going to spank you, if you use memory unwisely or
> something?  I'm trying to write a stupid program that
> works.  I don't care if Billy Bob at the CNC shop is
> psychotic or not and keeping a tally of unnecessary
> commands. 
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>     mailto:50g-fullfeatured@yahoogroups.com
>
>
>