Prev: IMAP4 package
Next: font with tk C API
From: Sooraj S on 28 Jun 2010 06:23 Hi, Is there any inbuild functions to convert a string to an integer in expect scripts..? ---- i have a string version with value "2108".. i want to find the older version ie 2108 -1 = 2107 and store it in another string old_version.. pls help me...
From: Uwe Klein on 28 Jun 2010 06:50 Sooraj S wrote: > Hi, > > Is there any inbuild functions to convert a string to an integer in > expect scripts..? > ---- > i have a string version with value "2108".. > i want to find the older version ie 2108 -1 = 2107 and store it in > another string old_version.. > > pls help me... > # if we assume version numbering to be contiguous: set version 2108 set old_version [ expr $version - 1 ] uwe
From: Harald Oehlmann on 29 Jun 2010 02:43 On 28 Jun., 12:50, Uwe Klein <uwe_klein_habertw...(a)t-online.de> wrote: > Sooraj S wrote: > > Hi, > > > Is there any inbuild functions to convert a string to an integer in > > expect scripts..? There are (at least) two possibilities to convert a string to a number. The following version might be a bit bullet-proof: set String "2108" if { 1 == [scan $String "%d" Number]} { incr Number puts [format "The number is %d" $Number] } else { return code error [format "String <%s> is not a number" $String] } Why use that ? To avoid interpretation of the string as octal number. Try: set String "012" incr String or: set String "009" incr String
|
Pages: 1 Prev: IMAP4 package Next: font with tk C API |