Post Reply 
Problems with export CMD
02-27-2017, 03:11 AM
Post: #4
RE: Problems with export CMD
(02-27-2017 01:14 AM)compsystems Wrote:  If you run for example inputv1a for first time x -> 0, then if you enter a value of 8, and then you close the program, the next execution appears x -> 8 and not x -> 0

It becomes zero when you recompile, for example when you edit the source code (prg editor calculator), or from the program editor of HPconnKit this is correct x -> 0

PHP Code:
export x:=0;
export inputv1a()

Why should it be zero? By design, the fact that you declared x outside of the scope of any program means that the variable x will never be destroyed (unlike local variables declared inside a function). The only exception is when you re-compile the program (which re-initializes x to whatever default value you use in your source code). This design ensures that x will always retain the last value stored into x. Using "export" merely allows x to be usable externally (i.e. by the user and any part of the system, not just the programs defined in the same source code where x was declared).

When you run inputv1a(), there is no code in that function that resets the value of x to 0. So of course it will retain the former value of 8. After all, the line "export x:=0;" exists outside of the definition of inputv1a().

This design allows programmers to create variables that remain in memory for other programs (within the same source file) to use/share.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
Problems with export CMD - compsystems - 02-27-2017, 12:47 AM
RE: Problems with export CMD - Carlos295pz - 02-27-2017, 01:02 AM
RE: Problems with export CMD - compsystems - 02-27-2017, 01:14 AM
RE: Problems with export CMD - Han - 02-27-2017 03:11 AM

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