The following warnings occurred:
Warning [2] Undefined array key 112519 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112524 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112566 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112587 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112624 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112629 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112661 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112677 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112678 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112524 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112624 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 112678 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





Creating local variables in RPL



#2

I am wondering if there are any more elegant ways of creating local variables aside from using ->.

I am trying to port some short C programs to the HP48/49, and since I haven't yet gotten to the stage where I do everything on the stack with things like PICK, DUP, and ROT I find I use quite a few local variables to keep track of things. In my programs, I am finding I have programs within programs, since local variable declarations need to be set apart from the routine in which they are used by <<. If I have, say, 8 local variables to declare, I have a rather inelegant declaration looking like this: << 0 0 0 0 0 0 0 0 -> a b c d e f g h << prgm >> >>. This of course is nested in another pair of <<>> brackets since I need to take my input off the stack into yet other local variables, so my overall program form may look like this:

<< -> x y << 0 0 0 0 0 0 0 0 -> a b c d e f g h << prgm >> >> >>

This is my RPL analogy to a function in C of the form float func(x,y).

Of course, I know that the zeros can (and should where possible) be initialized with values based on the x and y input, or whatever other starting values the program uses. My point is that this seems to be a rather complicated way to do a very simple thing.

Am I over complicating this? I must admit I came up with this approach by trial and error--took me a few hours, for example, to figure out that a local variable declaration must be followed immediately by an opening <<.

Grateful for whatever wisdom you can offer.

Les


#3

I assume that you mean in UserRPL, as using local variables in SysRPL is rather different; more flexible, but perhaps more complicated.

Try changing:

<< -> x y << 0 0 0 0 0 0 0 0 -> a b c d e f g h << prgm >> >> >>
to:
<< 0 0 0 0 0 0 0 0 -> x y a b c d e f g h << prgm >> >>
to create local variables x and y with two objects from the stack, and local variables a through h with initial values of 0, and then within << prgm >>, when the desired values become available, use 'a' STO, 'b' STO, etc. to replace the values of the existing local variables.

Current ROM revisions (starting with 1.19-4) for the 49 series also include the commands LOCAL for creating and initializing local variables from a list and UNBIND for deleting local variables, but I think that they're intended for ALG mode, and I don't know whether they can be used in RPN mode.

Regards,
James

#4

I have had some similar problems with LOCALS. It seems that the syntax wants to follow the minimum control path here, but don't assume that I have it figured out yet.

Here's what I think I know about it.

First, the local variables want to serve only the current program and the one being called by the level defining such variables LOCAL. If you do use a compiler, you can be a little more flexible. Since you apparently use the documentation, I advise using the "Advanced User Reference Manual" AND THE USER MANUAL. They seem to combine at times to resolve some things.

There is a method with a compiler, at least by indirect reference which might help some in your quest. Rather than try to paraphrase the method,I'll just point you to the subject - COMPILED LOCAL VARIABLES. This method ostensibly will allow you to use locals in all the succeeding program levels called directly in sequence after the initiating definition. This means that any definition performed at level 3 treats the COMPILED LOCAL designation using special naming convention will be treated as LOCAL within the sequence. Better research it yourself.

Best of luck,

Ron


#5

In UserRPL:

A procedure (program or algebric object) can use any local variable already existing or defined for it, provided that a more recently created local variable with the same name doesn't exist.

In other words, an "inner" procedure can use a local variable defined for any "outer" procedure, but an outer procedure can't use any local variable defined only for its inner procedures.

A new, entirely separate, local variable can be defined with the same name as an already existing local variable. Only the most recently created (inner-most) existing local variable with a particular name is accessible.

Note that the index of FOR loop is actually a local variable, existing for as long as the loop is running, so suppose that I define a local variable n for a program, and then use n as a FOR loop index name; in that case, any use of n within the loop uses the loop index, not the local variable n previously defined for the program.

Also, local names can be the same as command names, library command names, or global names. So you could have a local variable named, for example, SIN, or i, or e, in which case only the local variable could be accessed, not the command with the same name.

If you use the HALT command, or various other commands that suspend program execution, any existing local variable is retained, and may be used while the "suspended environment" exists, as long as a newer local variable with the same name doesn't exist.

I'd forgotten about "compiled local variables". Starting with the 48G series, any name beginning with a <- character will be compiled as a local name, even if a local variable with that name doesn't currently exist and isn't being created. This simplifies using a local variable within a program (to be stored in a global variable) which will be called by name from within another program which defines that local variable. But note that compiling the name as local doesn't actually create a local variable; to use a local variable, it has to be currently defined.

If you try to evaluate a local name for which no local variable is currently defined, you get (what else?) an "Undefined Local Name" error.

Regards,
James


#6

Thanks, James, for the details on local variables! As usual you show considerable research into the subject.

I am sure you understand this structure as you do the rest of it. I am puzzled by the distinguishing characteristics between RPN and RPL PROGRAMMING. Is it somehow similar to BASIC in that it can be compiled by USERRPL or run under an Interpreter? There so many good things hinted at by the instructions, but they fail ME) to produce the end result I think I am reading into it.

I think I will try to organize this thought in another post more on point by tomorrow and generate a question then. Kind of confusing in this topic.

Ron

#7

Quote:
In other words, an "inner" procedure can use a local variable defined for any "outer" procedure, but an outer procedure can't use any local variable defined only for its inner procedures.

I have capitalized on this fact in a little routine I just wrote to compute the incomplete beta function by its continued fraction expansion. The local variables a, b, and x are used both in the outer procedure, and in the inner procedure that specifically computes the continued franction. Indeed, whether or not x < (a+1)/(a+b+2) determines whether a, b and x are passed "straight" to the inner procedure or whether b, a, and 1-x are passed to a, b, and x in the inner procedure and the complementary function is computed by a reflection formula.

Despite James' initial advice, I have found that breaking up my local variable definitions in a "nested" way makes my programs easier to read and makes it very clear (at least to me) which procedure a local variable is local to.

Les


#8

Really enjoy the knowledge that flows between you two. I wonder if you or some will take on some relatively simple subjects, simple to many on this forum - but sometimes confusing to me.

What is the essential difference between RPL and RPN? Is it like the difference in Excel between the live,interpreted language of RPN and the pre-programed structure of the same language, with some few exceptions, referred to as RPL? A language that can be programmed and compiled via C++ or other compilers into machine language for more rapid execution. Using the case of "COMPILED LOCAL" variables, is this a description of variables compiled by the machine language compiler or by the process that uses the interpreter level, RPL, being a structured object made up of RPN commands, etc.?

In my book this would be very similer to BASIC INTERPRETER and QBASIC or VBASIC. By the way, I am speaking of the 50. So, does the COMPILED LOCAL VARIABLE have the flexibility discussed when it operates fully compiled as machine language or "compiled" as RPL? Is there a third alternative?

One more question, please. Is my system up-to-date and ready to share with Excel and Word? I get "Version HP50-C Revision #2.08"

Thanks,

Ron

Edited: 23 Apr 2007, 11:53 p.m.


#9

Hi, Ron --

Quote:
What is the essential difference between RPL and RPN?

Flippant answer:

RPN is like a sharp, no-nonsense dress shirt and trousers, but RPL is like a leisure suit.



Serious answer:

RPN is a means of calculation by postfix operation, in which operands are maintained in a stack, and operators are not stored, but are executed immediately upon request.

RPL is an adaptation of RPN to an object-oriented LISP-like structure, in which all forms of data -- simple forms such as actual numbers or display-setting values, or compound forms such as entire programs, entire matrices, or algebraic expressions -- are represented as "object types" that are carried in a dynamic-depth stack. Operations invariably "consume" their inputs, so that compound inputs are not preserved for subsequent use or re-trial unless previously saved to a named variable.

-- KS


#10

Karl a favorite professor used to say, "There's no such thing as a flippant answer, just flippant questions."

****************************************************

I always wondered how anyone could flunk a course in quantum theory when the possible answers to multiple response questions were:

****************************************************

probably so

probably not

who knows

who cares

not sure about the "uncertainty" principle

get a half-life!

******************************************************

Seriously, Karl. Thanks!

Edited: 24 Apr 2007, 2:01 p.m.


Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing RPL programs on OS X Sean Freeman 18 5,037 11-30-2013, 03:59 PM
Last Post: Sean Freeman
  HP: Dump the predefined variables! bluesun08 12 3,657 11-19-2013, 02:18 PM
Last Post: bluesun08
  48G vs 49G+ User RPL Speed Comparison John Colvin 7 2,536 11-16-2013, 10:07 PM
Last Post: Han
  RPL 32 David Hayden 4 2,027 11-11-2013, 11:34 AM
Last Post: David Hayden
  HP Prime - local variables retain their initial type BruceH 4 1,818 11-10-2013, 12:42 PM
Last Post: Michael de Estrada
  Shutdown with the Apps key and more than 10 variables in a program. Davi Ribeiro de Oliveira 10 3,750 11-05-2013, 01:26 PM
Last Post: Han
  HP Prime: Number of external Variables Davi Ribeiro de Oliveira 0 979 11-01-2013, 08:10 PM
Last Post: Davi Ribeiro de Oliveira
  HP Prime variables Davi Ribeiro de Oliveira 3 1,601 10-31-2013, 02:24 AM
Last Post: cyrille de Brébisson
  HP Prime - deleting variables bluesun08 1 1,190 10-29-2013, 06:36 PM
Last Post: Joe Horn
  HP Prime: CAS Variables - -How to save? Helge Gabert 2 1,754 10-27-2013, 11:26 PM
Last Post: Helge Gabert

Forum Jump: