cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
jetpeach
Level II

difference between set and new table variable - strange results in writing string?

could someone help me understand why  the 36D10 and 36E10 table variables come back expanded to sci notation? but seemingly only for 'new' instead of 'set' table variable?

Thanks,

--Peach

 

jetpeach_0-1634588739190.png

 

 

dt = New Table("Table");

testvar = "36D10";
dt << New Table Variable("tv_testD", char(testvar));

testvar = "36C10";
dt << New Table Variable("tv_testC", testvar);

testvar = "36F10";
dt << New Table Variable("tv_testF", testvar);

testvar = "36E10";
dt << New Table Variable("tv_testE", testvar);

testvar = "36E10";
dt << Set Table Variable("tv_testEset", testvar);
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: difference between set and new table variable - strange results in writing string?

E is for exponent and (a very long time ago) D for a double precision exponent.

 

I recommend using SETTableVariable; it behaves the way I'd expect: stores a number as a number and a string as a string and creates a table variable only if it isn't already there.

 

NEWTableVariable adds a suffix to the name if it already exists and, (the unexpected behavior), converts strings that look like numbers to numbers.

 

To further confuse things, dt<<GETTableVariable("name") returns a string, even if the value is numeric.

I recommend using dt:name to get the numeric value or the string value that is stored.

 

dt = New Table("Table");
dt << new Table Variable("a", char(17)); // 17 vs char(17)
show(dt:a,dt<<gettablevariable("a"));
dt<<settablevariable("a",42.42);
show(dt:a,dt<<gettablevariable("a"));
dt<<settablevariable("a","hello");
show(dt:a,dt<<gettablevariable("a"));
dt<<settablevariable("a",42.42);
show(dt:a,dt<<gettablevariable("a"));

dt:a = 17; <<< converted to a number
dt << gettablevariable("a") = "17"; <<< but fetched as a string !?!?!
dt:a = 42.42; <<< stored a number as expected
dt << gettablevariable("a") = "42.42"; <<< ?!?!? always returns a string
dt:a = "hello"; <<< stored a string as expected
dt << gettablevariable("a") = "hello"; <<< well, ok
dt:a = 42.42;
dt << gettablevariable("a") = "42.42";

Craige

View solution in original post

3 REPLIES 3
jthi
Super User

Re: difference between set and new table variable - strange results in writing string?

You could contact JMP support with this problem support@jmp.com

If you get a response which will explain the behaviour, please add new comment to this topic so everyone can learn.

-Jarmo
Craige_Hales
Super User

Re: difference between set and new table variable - strange results in writing string?

E is for exponent and (a very long time ago) D for a double precision exponent.

 

I recommend using SETTableVariable; it behaves the way I'd expect: stores a number as a number and a string as a string and creates a table variable only if it isn't already there.

 

NEWTableVariable adds a suffix to the name if it already exists and, (the unexpected behavior), converts strings that look like numbers to numbers.

 

To further confuse things, dt<<GETTableVariable("name") returns a string, even if the value is numeric.

I recommend using dt:name to get the numeric value or the string value that is stored.

 

dt = New Table("Table");
dt << new Table Variable("a", char(17)); // 17 vs char(17)
show(dt:a,dt<<gettablevariable("a"));
dt<<settablevariable("a",42.42);
show(dt:a,dt<<gettablevariable("a"));
dt<<settablevariable("a","hello");
show(dt:a,dt<<gettablevariable("a"));
dt<<settablevariable("a",42.42);
show(dt:a,dt<<gettablevariable("a"));

dt:a = 17; <<< converted to a number
dt << gettablevariable("a") = "17"; <<< but fetched as a string !?!?!
dt:a = 42.42; <<< stored a number as expected
dt << gettablevariable("a") = "42.42"; <<< ?!?!? always returns a string
dt:a = "hello"; <<< stored a string as expected
dt << gettablevariable("a") = "hello"; <<< well, ok
dt:a = 42.42;
dt << gettablevariable("a") = "42.42";

Craige
jetpeach
Level II

Re: difference between set and new table variable - strange results in writing string?

Thanks Craige, that helps clarify and establish how I should use.

Might be nice for something to be added to documentation, or perhaps the implementations of each changed in a future JMP version so they are consistent- it seems pretty hard for a user to know the differences in behavior with the current documentation (and the 'E' I immediately did think, 'oh it's doing something w/exponent - but the 'D' causing an issue really threw me for a loop).