Page 1 of 1

Error setting variable - bug?

PostPosted: Thu May 28, 2015 2:36 pm
by dpayer
I have a function that does a conversion on a string. I found that in some cases, I was getting an error. I tracked it down to the setting of a variable. Essentially, if I have a string that starts with numeric characters followed by e (or E) then additional numeric characters, NB converts this to a number. If additional non numeric characters are added, it is set as a string.
ImageImageImage

Is Neobook taking this as a log or using the natural number E?

When I define this variable as a string it solves the issue.

Is this an expected outcome? Are strings in the format of NNNeNNN where N=a number always to resolve to a number?

To test this, create a new publication sized 320x200 and paste this code into it.
Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5.80
ObjectType=3
Name=PushButton2
X=171
Y=121
W=138
H=69
Anchor=0
Text=SetVar
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=SetVar "[testXX]" "[test]"¶AlertBox "test" "[testXX]"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ObjectType=8
Name=Text1
X=17
Y=25
W=289
H=56
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 SetVar "\{testXX\}" [test]"\par\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 AlertBox "test" "\{testXX\}"}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=3
ObjectType=9
Name=TextEntry4
X=29
Y=126
W=111
H=34
Anchor=0
VarName=[test]
Align=1
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=4
ObjectType=8
Name=Text2
X=10
Y=87
W=271
H=30
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 test any number followed by E then number}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=5

Re: Error setting variable - bug?

PostPosted: Thu May 28, 2015 5:13 pm
by Gaev
David P:

When I define this variable as a string it solves the issue.
Or use the Exclamation Mark ! before the string value.

Is Neobook taking this as a log or using the natural number E?
Is this an expected outcome? Are strings in the format of NNNeNNN where N=a number always to resolve to a number?
I am not sure ... e is supposed to be 2.718281828 ... when it does calculations on the parameter string, it seems to return ...

nothing for e
00 for e2
000 for e3

Take a look at the results when you try these different tests ...
Code: Select all
SetVar "[gkresult1a]" "!e"
SetVar "[gkresult1b]" "e"
SetVar "[gkresult2a]" "!1e"
SetVar "[gkresult2b]" "1e"
SetVar "[gkresult3a]" "!1e2"
SetVar "[gkresult3b]" "1e2"
SetVar "[gkresult4a]" "!12e3"
SetVar "[gkresult4b]" "12e3"
SetVar "[gkresult5a]" "!6e3abc"
SetVar "[gkresult5b]" "6e3abc"
SetVar "[gkresult6a]" "!Math exp(2)"
Math "exp(2)" "6" "[gkresult6b]"
SetVar "[gkresult11a]" "!sin(60)"
SetVar "[gkresult11b]" "sin(60)"
SetVar "[AlertResult]" "![gkResult1a] = [gkResult1b]"
SetVar "[AlertResult]" "![AlertResult][#13][#10][gkResult2a] = [gkResult2b]"
SetVar "[AlertResult]" "![AlertResult][#13][#10][gkResult3a] = [gkResult3b]"
SetVar "[AlertResult]" "![AlertResult][#13][#10][gkResult4a] = [gkResult4b]"
SetVar "[AlertResult]" "![AlertResult][#13][#10][gkResult5a] = [gkResult5b]"
SetVar "[AlertResult]" "![AlertResult][#13][#10][gkResult6a] = [gkResult6b]"
SetVar "[AlertResult]" "![AlertResult][#13][#10][gkResult11a] = [gkResult11b]"
Alertbox "Done" "![AlertResult]"

Re: Error setting variable - bug?

PostPosted: Fri May 29, 2015 9:09 am
by Neosoft Support
NeoBook thinks your variable is in scientific notation. See "E-Notation" in this article: http://en.wikipedia.org/wiki/Scientific_notation

Placing an exclamation point character "!" in front of the value will solve the problem.

Re: Error setting variable - bug?

PostPosted: Fri May 29, 2015 9:33 am
by dpayer
Neosoft Support wrote:NeoBook thinks your variable is in scientific notation. See "E-Notation" in this article: http://en.wikipedia.org/wiki/Scientific_notation

Placing an exclamation point character "!" in front of the value will solve the problem.


Thanks for the clarification. I was doing a conversion of ESNs and Hex numbers to Decimal in my efforts and it appears this kind of string unintentionally occurred quite often.

Re: Error setting variable - bug?

PostPosted: Sat May 30, 2015 11:02 am
by Neosoft Support
It's unusual. I don't think anyone has stumbled across this exact problem before.