Source language: Translate to:

Defining/Declaring Decimal or Integrer Variables?

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Defining/Declaring Decimal or Integrer Variables?

Postby redjr » Tue May 19, 2009 8:20 am

If you have a variable that contains a number, do you have to DefineVar it to a number before using it with the Math command?

I'm trying to read the contents of a file that contians both text as numbers, and add up the number values during a loop command, but keep getting an ERROR value when I output my variable.

Can I simply use;

Math "[TBAC] + [SBAC]" "" "[TBAC]"

Thx,
redjr...
User avatar
redjr
 
Posts: 80
Joined: Tue Jan 06, 2009 2:49 pm
Location: NY

Numbers...

Postby virger » Tue May 19, 2009 8:50 am

The variables need be Numbers
[TBAC]..number
[SBAC]..number

setvar "[TBAC]" "1"
setvar "[SBAC]" "3"
math "[TBAC] + [SBAC]" "" "[TBAC]"

OKI

setvar "[TBAC]" "1hi" (this is a string)

or
setvar "[SBAC]" "hi3" (this is a string)

math "[TBAC] + [SBAC]" "" "[TBAC]"

ERROR....


PURA VIDA
FROM COSTA RICA
CENTRAL AMERICA
User avatar
virger
 
Posts: 510
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Re: Numbers...

Postby redjr » Tue May 19, 2009 11:57 am

virger wrote:The variables need be Numbers
[TBAC]..number
[SBAC]..number

setvar "[TBAC]" "1"
setvar "[SBAC]" "3"
math "[TBAC] + [SBAC]" "" "[TBAC]"

OKI

setvar "[TBAC]" "1hi" (this is a string)

or
setvar "[SBAC]" "hi3" (this is a string)

math "[TBAC] + [SBAC]" "" "[TBAC]"

ERROR....

I understand they need to be numbers, but do they need to be defined as integers, or decimals, etc. They are being read in from a .txt file, so I need to be sure they are interpreted as integers or decimal values as opposed to text values. Hence do I need to assigned them to an integer variable.

I know you can't add 1hi and hi3!

redjr...

PURA VIDA
FROM COSTA RICA
CENTRAL AMERICA
User avatar
redjr
 
Posts: 80
Joined: Tue Jan 06, 2009 2:49 pm
Location: NY

Postby Gaev » Tue May 19, 2009 12:46 pm

redjr:

In NeoBook you don't need to define any variable.

But if you are going to use the Math command, you need to make sure that the involved [variables] have a numeric content at the time you invoke the command ... NeoBook will handle 45 just as easily as -9.67
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests