Source language: Translate to:

Error setting variable - bug?

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Error setting variable - bug?

Postby dpayer » Thu May 28, 2015 2:36 pm

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
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Error setting variable - bug?

Postby Gaev » Thu May 28, 2015 5:13 pm

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]"
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Error setting variable - bug?

Postby Neosoft Support » Fri May 29, 2015 9:09 am

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.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Error setting variable - bug?

Postby dpayer » Fri May 29, 2015 9:33 am

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.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Error setting variable - bug?

Postby Neosoft Support » Sat May 30, 2015 11:02 am

It's unusual. I don't think anyone has stumbled across this exact problem before.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests