Post Reply 
HP-48G local variables within subroutine
05-18-2023, 12:24 AM
Post: #9
RE: HP-48G local variables within subroutine
Hello,

@Boub65
If I understand you correctly, in your example a local variable named (e.g.) local_c could exist in the main program but also in a subroutine.

⇒ First possibility

As 2old2randr explains, you can use nested code(s) in the main program kind.

⇒ 2nd possibility

Now, you need to use the variable local_c in both a main program and one (or more) distinct subroutine(s); then local_c must be a compiled local variable.
This is the only case where compiled local variables are needed. Their names begin always with a left arrow: ←local_c
This type of variable did not exist on hp-28. It must have been created for the 48G/GX/G+ serie, if I'm not mistaken, and was kept for later RPL models.

So, one example:

Main program
Code:

<< → a b ←c   @ declaration/initialization of the local variables / compiled or not
   << ... called_SUBR ...
   >>
>>

called_SUBR
Code:

<< → d e f … @ possible local variables specific of the subroutine / they may be called a, b, c, but beware of confusion…
   <<
      ... ←c ...   @ use of the compiled variable c previouly declared/initialized in the main program
   >>
>>

And don't forget that a variable, whether local or not, compiled or not, can contain any kind of object: numbers and strings of course, but also algebraic objects, lists, pieces of code (which can be, if needed, some kind of functions that you can carry anywhere in your application), the name of another variable... and even a directory.
It's just a matter of need, taste and creativity.

Best regards

Bruno
Sanyo CZ-0124 ⋅ TI-57 ⋅ HP-15C ⋅ Canon X-07 + XP-140 Monitor Card ⋅ HP-41CX ⋅ HP-28S ⋅ HP-50G ⋅ HP-50G
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP-48G local variables within subroutine - FLISZT - 05-18-2023 12:24 AM



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