[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    Re: [sqlite] Expr error in TCL
From:       <lawrence.chitty () ntlworld ! com>
Date:       2005-01-28 9:17:21
Message-ID: 20050128091803.IOKR3971.aamta07-winn.mailhost.ntl.com () [62 ! 253 ! 162 ! 61]
[Download RAW message or body]

Hi Anirban

I recently suggested to you 2 very good resources for these sort of questions. I \
really recommend you use them as you will find answers much more forthcomming.

The problem you have is a common problem where numbers with leading 0's are \
interpreted as octal numbers. To solve this, the number can be reformatted to remove \
the 0's . The method recommended on the Tcl'ers Wiki is to use the scan command.

e.g.

scan $prv_rd %d prv_rd
set calc [expr $prv_rd+2]

Lawrence

> 
> From: "Anirban Sarkar" <anirban.sarkar@cescltd.com>
> Date: 2005/01/28 Fri AM 08:25:54 GMT
> To: <sqlite-users@sqlite.org>
> Subject: [sqlite] Expr error in TCL
> 
> The $prv_rd variable stores backend sqlite data (varchar data type). The data is \
> 0000874. In order to perform any mathematical operation on this data, I use : 
> set calc [expr $prv_rd+2]
> 
> The above expression gives me the following error message :
> 
> Error : expected integer but got "0000874" ( looks like invalid octal number )
> 
> How do I get rid of this error?
> Any early help will be appreciated.
> 
> Thanks.
> Anirban Sarkar
> 

-----------------------------------------
Email provided by http://www.ntlhome.com/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic