Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!rice!uw-beaver!milton!ogicse!intelhf!ichips!iwarp.intel.com!inews!natukawa!mbodas From: mbodas@natukawa.intel.com (Milind Bodas) Newsgroups: comp.unix.shell Subject: AWK:String <--> Integer ?? Keywords: awk Message-ID: <3135@inews.intel.com> Date: 20 Mar 91 03:12:18 GMT Sender: news@inews.intel.com Reply-To: mbodas@natukawa.intel.com (Milind Bodas) Followup-To: mbodas@natukawa.intel.com Organization: Intel Corporation Lines: 29 Hello, When a variable is assigned using substr() function in an awk script, it seems that it cann't be used in certain numerical/logical operations. For example in following piece of code, the for loop is executed only 4 times instead of 38 times - i1 = index($1,"["); i2 = index($1,":"); i3 = index($1,"]"); last = substr($1,i1+1,i2-i1-1); first = substr($1,i2+1,i3-i2-1); #last = last + 10 - 10 #last = last + 10 - 10 for (i=first;i<= last;i++) { print $0 } the corresponding input provided is fwefeffwfgwf absffg[37:0] dwfdwfdfwfwff However if I insert the commented lines, it works fine. Does anyone know what's wrong? Milind Bodas Intel Corporation