Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with format in TCL 8.4

Status
Not open for further replies.

zombieZero

Technical User
Apr 7, 2004
28
US
I have a proc that converts hex IP address and hex mask into a broadcast address. This worked with TCL 8.3 but I'm hitting a problem with TCL 8.4

Basically, the proc does the following:

set hexIP 80010101
set hexMASK ffff0000
set IPM [expr ( $hexIP | $hexMASK ) ]
-2147352577

format "%08x" $IPM
8001ffff

...Then I convert that value into dotted decimal. This works fine in 8.4 as long as the first octet of the IP address is 128 or higher...if that first bit isn't on, then it fails when the proc is called and nothing is returned.

I put in some debug and found that it is when format is called that it's getting lost...the debug statement after the format never even gets called, as if it somehow got lost somewhere in format itself.

The strange thing is, if I just issue the commands from the shell, it seems to work, but from within the procs themselves it fails every time.

Has anyone else encountered anything like this?
 
Is this what you need?
Code:
  set hexIP 80010101
  set a1 [string range $hexIP 0 1]
  set a2 [string range $hexIP 2 3]
  set decMask [expr 0x$a1].[expr 0x$a2].255.255
  puts $decMask
[red]128.1.255.255[/red]

HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top