From: Sooraj S on
Hi,
i have a string version in my expect script. I want to convert it to
1.2.3.4
------
set version 1234
----
can anyone pls guide me..

From: Uwe Klein on
Sooraj S wrote:
> Hi,
> i have a string version in my expect script. I want to convert it to
> 1.2.3.4
> ------
> set version 1234
> ----
> can anyone pls guide me..
>
# create a list of single digits
set verlist [ split $version {} ]
# joint list with "."
set withdots [ join $verlist . ]

and back:
# split string on "."
set verlist [ split $withdots . ]
# join list with "" ( i.e an empty string )
set version [ join $verlist {} ]


something like this? ( Only works if all version elements are single digit )

uwe
From: Helmut Giese on
Hi,
remove the '.'s by "mapping" them to "nothing":
set version 1.2.3.4
set noDots [string map {. ""} $version]
HTH
Helmut Giese

>Hi,
>i have a string version in my expect script. I want to convert it to
>1.2.3.4
>------
>set version 1234
>----
>can anyone pls guide me..

From: Sooraj S on
Hi Klein,

Thanks for your help..it worked...

I got it in another way also..pls do tell me if the code looks junk..

----
set version "1234"
set len [string length $version]
for {set i 0} {$i < $len} {incr i} {
set s [string index $version $i]
append new_version $s
if {$i <= $len-1} {
append new_version "."
}
}
puts "Version : $new_version" # new_version 1.2.3.4


From: Sooraj S on
Hi Klein,

Thanks for your help .... it worked...

i got it in another way also... do tell me if the code looks junk...

set len [string length $version]
for {set i 0} {$i < $len} {incr i} {
set s [string index $version $i]
append version_dot $s
puts "\nCheck$i : $version_dot"
if {$i <= $len-1} {
append version_dot "."
}
}
puts "Version : $version_dot"