#38375 - 2003-03-26 02:55 AM
Problem on UDF involving IP ADDRESS
|
lpuyod
Fresh Scripter
Registered: 2002-02-05
Posts: 9
Loc: Philippines
|
My test machine : KiXtart 2001 4.20 IP Address. . . . . . . . . . . . : 10.0.28.49 Subnet Mask . . . . . . . . . . . : 255.0.0.0 Default Gateway . . . . . . . . . : 10.16.64.1
Problem: ERROR : array reference out of bounds! Script: C:\WINNT\iptest3.KIX Line : 102
code:
function ipmask($ipaddress1, $ipaddress2) Dim $bit if instr($ipaddress1,'.') or instr($ipaddress2,'.') or len($ipaddress1)<>32 or
len($ipaddress2)<>32 exit 87 endif $ipmask='' for $bit=1 to 32 $ipmask=$ipmask+(val(substr($ipaddress1,$bit,1)) & val(substr($ipaddress2,$bit,1))) next endfunction function isiniprange($ipaddress,$iprangearray) Dim $iprange, $networkid, $subnetmask, $bit
if $ipaddress='' exit 87 endif
$ipaddress=binaryip($ipaddress)
for each $iprange in $iprangearray
if instr($iprange,'/') $iprange=split($iprange,'/') $networkid=binaryip($iprange[0])
if instr($iprange[1],'.') $subnetmask=binaryip($iprange[1]) else $subnetmask='' for $bit=1 to val($iprange[1]) $subnetmask=$subnetmask+'1' next for $bit=(val($iprange[1])+1) to 32 $subnetmask=$subnetmask+'0' next endif
if isinsubnet($ipaddress,$networkid,$subnetmask) $isiniprange=1 return else $isiniprange=0 endif endif next endfunction DIM $iparray[0] DIM $iparray[1] DIM $iparray[2] $ipaddress=@IPADDRESS0 $iparray[0]='10.0.28.0/24' $iparray[1]='10.0.40.0/24' $iparray[2]='10.0.27.0/24 call "isiniprange.udf" IF isiniprange($ipaddress,$iparray[0]) MessageBox ("Welcome to IRRI",0,35 ) ENDIF :EXIT Exit
Also Tried this Code:
$ipaddress=@IPADDRESS0 $iparray[0]='10.0.28.0/24' $iparray[1]='10.0.28.0/255.255.255.0' $iparray[2]='10.0.28.49/255.0.0.0' IF isiniprange($ipaddress,$iparray) MessageBox ("Welcome to IRRI",0,35 ) ENDIF
{edit}Bullock - Added CODE tags, But the code was not properly indented. Please edit your code use proper indentation to assist in the readablility of your code. [ 26. March 2003, 12:58: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#38376 - 2003-03-26 06:52 AM
Re: Problem on UDF involving IP ADDRESS
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
lpoyud,
May I make a recommendation? Can you post your code between the [CODE]..[/CODE] tags? Use the Code Button below to do so when creating a post.
Anyway, here is what was found..
Ran your code through KiXStrip and see the following:
quote:
$iparray[2]='10.0.27.0/24 ; -------> Warning KIXSTRIP: 53 line incomplete "single quotation". ; -------> Warning KIXSTRIP: 53 line incompleted.
KiXStrip can be found here - http://home.wanadoo.nl/scripting/
HTH,
Kent
|
|
Top
|
|
|
|
#38379 - 2003-03-31 07:02 AM
Re: Problem on UDF involving IP ADDRESS
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
Can you put your current version also on the board? greetings.
btw: no errors found doesn't always mean you script works in a correct way.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(mole)
and 1300 anonymous users online.
|
|
|