danjmw
10-17-2006, 08:45 PM
I'm having trouble understanding why I can not read from a list with a variable created from input (please keep in mind I'm new to applescript and scripting in general). I have a list constructed as follows:
set maskValuesA to {bit8:"0", bit9:"128", bit10:"192", bit11:"224", bit12:"240", bit13:"248", bit14:"252", bit15:"254"}
set maskValuesB to {bit16:"0", bit17:"128", bit18:"192", bit19:"224", bit20:"240", bit21:"248", bit22:"252", bit23:"254"}
set maskValuesC to {bit24:"0", bit25:"128", bit26:"192", bit27:"224", bit28:"240", bit29:"248", bit30:"252", bit31:"254"}
the script pulls an integer from a table (the integer is a bit value of a subnet from an IP host/network definition) and attaches the string "bit" to it in the following line (targetIPsub is the integer):
set targetIPbit to "bit" & targetIPsub
the script is to then run targetIPbit through the list to retrieve the correct subnet value:
if targetIPsub is less than "16" then
set ipMask to targetIPbit of maskValuesA
set targetIPmask to "255." & ipMask & ".0.0"
else
if targetIPsub is less than "24" then
set ipMask to targetIPbit of maskValuesB
set targetIPmask to "255.255." & ipMask & ".0"
else
if targetIPsub is less than "32" then
set ipMask to targetIPbit of maskValuesC
set targetIPmask to "255.255.255." & ipMask
else
set targetIPmask to "255.255.255.255"
end if
end if
end if
if I have the script print out targetIPsub it shows the value correctly, but I receive the following error (w/ a value between 24 and 31):
Can't get targetIPbit of {bit24:"0", bit25:"128", bit26:"192", bit27:"224", bit28:"240", bit29:"248", bit30:"252", bit31:"254"}.
now, if I declare targetIPbit directly, such as:
set targetIPbit as bit24
then I can pull from the table. what am I missing?
set maskValuesA to {bit8:"0", bit9:"128", bit10:"192", bit11:"224", bit12:"240", bit13:"248", bit14:"252", bit15:"254"}
set maskValuesB to {bit16:"0", bit17:"128", bit18:"192", bit19:"224", bit20:"240", bit21:"248", bit22:"252", bit23:"254"}
set maskValuesC to {bit24:"0", bit25:"128", bit26:"192", bit27:"224", bit28:"240", bit29:"248", bit30:"252", bit31:"254"}
the script pulls an integer from a table (the integer is a bit value of a subnet from an IP host/network definition) and attaches the string "bit" to it in the following line (targetIPsub is the integer):
set targetIPbit to "bit" & targetIPsub
the script is to then run targetIPbit through the list to retrieve the correct subnet value:
if targetIPsub is less than "16" then
set ipMask to targetIPbit of maskValuesA
set targetIPmask to "255." & ipMask & ".0.0"
else
if targetIPsub is less than "24" then
set ipMask to targetIPbit of maskValuesB
set targetIPmask to "255.255." & ipMask & ".0"
else
if targetIPsub is less than "32" then
set ipMask to targetIPbit of maskValuesC
set targetIPmask to "255.255.255." & ipMask
else
set targetIPmask to "255.255.255.255"
end if
end if
end if
if I have the script print out targetIPsub it shows the value correctly, but I receive the following error (w/ a value between 24 and 31):
Can't get targetIPbit of {bit24:"0", bit25:"128", bit26:"192", bit27:"224", bit28:"240", bit29:"248", bit30:"252", bit31:"254"}.
now, if I declare targetIPbit directly, such as:
set targetIPbit as bit24
then I can pull from the table. what am I missing?