HP Forums
Global Variable - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Global Variable (/thread-3440.html)



Global Variable - Powersoft - 03-20-2015 06:53 PM

This is a simple test.
Try to fill this EXPORTED var3 with subroutine.
var1 and var2 have values, but var3 keeps on zero.
What is wrong on this?

Cheers,

Jan

TEST(); // Declaration of the subroutine
EXPORT var1,var2,var3; //Exported variable
EXPORT F1 ()
BEGIN
TEST(); // Call TEST and fill var3 with value
INPUT({var1,var2},{"var1=","va2="});
RETURN var1+var2;
END;

TEST()
BEGIN
var3:=12345.6789;
END;


RE: Global Variable - DrD - 03-21-2015 02:02 PM

Changed the INPUT(..) line. This should work:

Code:

TEST(); // Declaration of the subroutine
EXPORT var1:=0,var2:=0,var3:=0; //Exported variable
EXPORT F1 ()
BEGIN
TEST(); // Call TEST and fill var3 with value
 
INPUT({{var1,[0],{25,50,0}},{var2,[0],{25,50,1}}});
  
RETURN var1+var2;
END;

TEST()
BEGIN
var3:=12345.6789;
END;



RE: Global Variable - John Colvin - 03-21-2015 08:23 PM

(03-20-2015 06:53 PM)Powersoft Wrote:  This is a simple test.
Try to fill this EXPORTED var3 with subroutine.
var1 and var2 have values, but var3 keeps on zero.
What is wrong on this?

Cheers,

Jan

TEST(); // Declaration of the subroutine
EXPORT var1,var2,var3; //Exported variable
EXPORT F1 ()
BEGIN
TEST(); // Call TEST and fill var3 with value
INPUT({var1,var2},{"var1=","va2="});
RETURN var1+var2;
END;

TEST()
BEGIN
var3:=12345.6789;
END;
Your program works fine on my Prime as is. I get var3 value as assigned.
I have the same firmware and Model as you. Runs fine on both the emulator and
the real Prime.


RE: Global Variable - Han - 03-22-2015 02:30 AM

(03-20-2015 06:53 PM)Powersoft Wrote:  This is a simple test.
Try to fill this EXPORTED var3 with subroutine.
var1 and var2 have values, but var3 keeps on zero.
What is wrong on this?

Cheers,

Jan

TEST(); // Declaration of the subroutine
EXPORT var1,var2,var3; //Exported variable
EXPORT F1 ()
BEGIN
TEST(); // Call TEST and fill var3 with value
INPUT({var1,var2},{"var1=","va2="});
RETURN var1+var2;
END;

TEST()
BEGIN
var3:=12345.6789;
END;

Check and see if var3 isn't also an already existing variable (prior to creating your program).