HP71B/75: How to use SUB, ENDSUB, CALL
|
09-10-2016, 12:16 AM
Post: #1
|
|||
|
|||
HP71B/75: How to use SUB, ENDSUB, CALL
Question for the HP 71B/75 experts:
How do I use SUB, END SUB, and CALL? Is it really any different from using GOSUB and RETURN using line numbers? Thanks. |
|||
09-10-2016, 01:40 AM
Post: #2
|
|||
|
|||
RE: HP71B/75: How to use SUB, ENDSUB, CALL
(09-10-2016 12:16 AM)Eddie W. Shore Wrote: Question for the HP 71B/75 experts: Yes, the CALL sub is different. General syntax: SUB <subname>(<list of parameters>) <statements> END SUB CALL <subname>(<list of arguments>) The data type (and scalar/array designations) of the argument list must match that of the parameter list. Parameters that are arrays are passed by reference. Reference manual not clear about non-array parameters. Enclosing an argument in () makes it passed by value. Arrays must include () (such as A()). Two or more dimensional arrays must include commas to indicate the number of dimensions So , A(,) indicates that it is a matrix. I encourage you to consult the HP-71B and HP75C/D documentation. |
|||
09-10-2016, 03:43 AM
(This post was last modified: 09-10-2016 03:44 AM by Garth Wilson.)
Post: #3
|
|||
|
|||
RE: HP71B/75: How to use SUB, ENDSUB, CALL
A nice thing about SUBprograms is that they have local environments, so they don't step on identically named variables, etc. from other programs or subprograms that might be pending. A subprogram can even call itself recursively, up to 63 levels deep IIRC, and each level will have its own environment. The subprogram does not have to be in the same program file; and if there might be two or more subprograms with the same name, you can specify where to look to find the right one. The CALL can also be indirect, with the subprogram's name being in a string. It's really quite powerful. The list in input and output parameters can be quite long. This is all 71 stuff. I don't know if the 75 differs.
http://WilsonMinesCo.com (Lots of HP-41 links at the bottom of the links page, at http://wilsonminesco.com/links.html#hp41 ) |
|||
09-10-2016, 01:26 PM
Post: #4
|
|||
|
|||
RE: HP71B/75: How to use SUB, ENDSUB, CALL | |||
09-11-2016, 01:51 AM
Post: #5
|
|||
|
|||
RE: HP71B/75: How to use SUB, ENDSUB, CALL
(09-10-2016 01:26 PM)Namir Wrote:(09-10-2016 12:16 AM)Eddie W. Shore Wrote: Question for the HP 71B/75 experts: Looking forward to it, Eddie |
|||
09-11-2016, 09:21 AM
Post: #6
|
|||
|
|||
RE: HP71B/75: How to use SUB, ENDSUB, CALL
If you do a PDF search for "subprogram" in The Titan File Collection, you'll find many simple examples, as well as explanations of why these short programs are best as SUBprograms rather than regular programs.
<0|ɸ|0> -Joe- |
|||
09-11-2016, 12:11 PM
Post: #7
|
|||
|
|||
RE: HP71B/75: How to use SUB, ENDSUB, CALL
Very cool file Joe!!
|
|||
09-13-2016, 01:20 PM
Post: #8
|
|||
|
|||
RE: HP71B/75: How to use SUB, ENDSUB, CALL
Thank you Joe!
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)