The following warnings occurred:
Warning [2] Undefined array key 94967 - 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 94968 - 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 94974 - 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 94979 - 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 94985 - 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 94987 - 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 95029 - 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 95149 - 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 95158 - 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 95186 - 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 95158 - 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 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 95186 - 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 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





Verifying existence of a variable



#11

Please excuse me if this is covered elsewhere. If it is, I haven't found it.

In a program, I want to store and retrieve the result of calculatgion in a matrix named M1.

Sometimes, I stop the program partway through the procedure and restart the next day.

It is a simple matter to have...

<< -> xin yin zin tin 
<< ..........
{calculations....result in the form of:}

[xout yout zout tout]
Rownumber
M1

{test dimensions of M1, redimension if needed}

{put vector [xout yout zout tout] into correct row of M1}
>>

The problem I have not solved is "How to have the program test for the existence of M1 prior to running the program, because if M1 exists when I restart, then I do not want to re-initialize it.


#12

It looks like your code is in RPL. Do you have an HP48 by any chance? If so, there is a command called VTYPE which takes a variable name and returns the type of object stored in that variable. If nothing is stored in that variable, a -1 is returned to the stack.

Quote:
Please excuse me if this is covered elsewhere. If it is, I haven't found it.

In a program, I want to store and retrieve the result of calculatgion in a matrix named M1.

Sometimes, I stop the program partway through the procedure and restart the next day.

It is a simple matter to have...

<< -> xin yin zin tin 
<< ..........
{calculations....result in the form of:}

[xout yout zout tout]
Rownumber
M1

{test dimensions of M1, redimension if needed}

{put vector [xout yout zout tout] into correct row of M1}
>>

The problem I have not solved is "How to have the program test for the existence of M1 prior to running the program, because if M1 exists when I restart, then I do not want to re-initialize it.




#13

Yes, I do have a 48. Actually 2, a 48g and a 48gx. I started with a 21, upgraded to a 41C when it first came out and finally got these 48's on sale in 1995 more or less.

I learned to use and program the 41C in one weekend, but the 48s were not what I expected, so they mostly sat for the past ten years.

Learning now to use them. It's not so bad.

Thank you for the info on VTYPE. It will be used!

Also, I figured out that merely putting the variable name into an

IFFERR Variablename 
THEN
ELSE
END

structure would not generate an error, but that putting the name there and then trying to RCL would generate an error which I could trap.

Two solutions in only one afternoon.


#14

Here's another method. If you know the type of the object stored under a particular variable, you can also use the TYPE command:

IF M1 DUP TYPE 6 == THEN "Nothing stored in 'M1'" END

Notice that M1 is called; if nothing is stored in M1, then the variable name is simply placed onto the stack. Otherwise, the contents of the variable is called onto the stack.

May I also suggest the Advanced User's Reference Guide? It is freely available in PDF at www.hpcalc.org. This reference details every single built-in command in the HP48G/GX. There is also a similar guide for the HP48S/SX called the HP48 Programmer's Reference Guide (available on the CDs from this museum).


Han


Edited: 25 June 2006, 11:07 p.m.


#15

Han,

Yes, the Advanced User's Manual. Downloaded. 764 pages. May not print it right away.

Thx for the other tip. I got the programs to work. Ode to Joy, etc.

If you don't mind, one other thing I need to figure out it this:

<< -> variablename << ..... yields a local variable for use within the program and it frees up memory after termination.

But, is there some way to declare other local variables which do not correspond to values on the stack?

-James

H


#16

A local variable can't be created without a value (taken from the
stack) to store in it.

What you can do is, at the beginning of the program, put "dummy"
values on the stack and store them into local variables. Later,
when you have something you want to store in one of
these local variables, put its quoted name on the stack and use
the STO command. For example:

%%HP: T(3);
\<< @ Begin program.
0 0 0 @ Dummy values for local variables.
\-> a b c @ Bind local variables.
\<< @ Begin defining procedure for local variables.
\<< @ Begin subprogram.
"My subprogram, possibly using local variable 'b' or 'c'"
\>> @ End subprogram, leaving it on stack.
'a' STO @ Store subprogram in local variable 'a'.
@ Do whatever, using local variables 'a',
@ 'b' and 'c' as desired.
\>> @ End defining procedure, abandoning local
@ variables.
\>> @ End program.
Regards,
James

Edited: 26 June 2006, 9:09 a.m.


#17

Actually, this is good news. It means I did not misread the manual. (ha!)

There does not need to be as many dummy variables as there are unique intermediate results, only as many as there are unique intermediate result at one time.

With graditude,


#18

Beware that these local variables are not accessible from programs called from the program where they were created.

Example : program ZZZ creates local variable PPP.

ZZZ calls TTT.

TTT cannot access PPP.

Sad.



There is actually a way to circumvent this fatal flaw, it involves the use of a back arrow (<-) in front of the variable name, I have never dug that far. Now you know why I do't touch RPL even with a very long fork.


#19

This is explained in the Advanced User's Guide. Any local variable whose name starts with the <- symbol has larger scope than one without.

#20

Quote:
Beware that these local variables are not accessible from programs called from the program where they were created.

...

There is actually a way to circumvent this fatal flaw...


Visibility rules in structured languages typically don't allow the access to variables that a calling function defines from the called function, if the functions aren't nested, i. e. the called function is *defined* whithin the caller. (C and C++ don't have a means to nest functions in code, Java can do it by nesting classes.)

Assume the following:

  1. A function 'FA' makes use of a variable named 'VA' which is assumed to exist outside the function, a global variable.
  2. Another function 'FB' defines a local variable with name 'VA' for some internal purpose.
  3. Now, 'FB' calls 'FA'. If 'VA' as defined in 'FB' were visible in the called function 'FA', an undesired side effect would occur.

If you really wanted 'FA' to modify the local variable 'VA' in 'FB' instead of a global variable, you need to nest the code. Then it's clear what is meant with the identifier 'VA'.

Marcus


Possibly Related Threads…
Thread Author Replies Views Last Post
  hp-prime solver and variable name fabrice48 22 8,120 12-10-2013, 03:25 AM
Last Post: fabrice48
  Prime: Scope of Variable and functions within programs Thomas Chrapkiewicz 9 3,249 11-18-2013, 03:39 PM
Last Post: Thomas Chrapkiewicz
  HP Prime - Variable problem bluesun08 12 3,458 11-07-2013, 11:34 AM
Last Post: bluesun08
  50G variable issue Matt Agajanian 8 2,401 05-21-2012, 03:14 PM
Last Post: Matt Agajanian
  Reminders/notes to help recall variable meanings in equations Chris C 11 2,940 02-16-2012, 06:53 PM
Last Post: Bart (UK)
  WP34s - Verifying Flashing Thomas Chrapkiewicz 6 1,775 07-11-2011, 05:32 PM
Last Post: Paul Dale
  Optimizing programs: Writing a number VS calling a variable Pablo P (Spain) 4 1,420 07-12-2010, 11:25 AM
Last Post: Katie Wasserman
  OT: Continuously Variable Gear Transmission Norman Dziedzic 12 3,473 05-17-2010, 01:52 PM
Last Post: Garth Wilson
  HP20b's 1-variable weighted function Ric Lombardo 6 1,908 04-30-2010, 11:09 AM
Last Post: Gene Wright
  compiled local variable DK2ZA 5 1,476 10-08-2009, 01:10 PM
Last Post: Vieira, Luiz C. (Brazil)

Forum Jump: