There is a KIX function called "SPLIT" which will let you parse the IP
address into its 4 octet components.

 

$mysubnetList = Split ($myaddress,".")

 

The second octet would be $mysubnetList[1]         (array indexes start at
0).

 

 

From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com]
On Behalf Of Marcum, John
Sent: Monday, November 25, 2013 8:15 am
To: scripting@lists.myitforum.com
Subject: RE: [scripting] Simple KIX Question

 

I was curious if it was smart enough to know that one character could be a
period and ignore it. I guess not. :-)

 

 

  _____  

John Marcum
Sr. Desktop Architect

Bradley Arant Boult Cummings LLP

  _____  

 

From: listsad...@lists.myitforum.com <mailto:listsad...@lists.myitforum.com>
[mailto:listsad...@lists.myitforum.com] On Behalf Of Trevor Sullivan
Sent: Monday, November 25, 2013 9:51 AM
To: scripting@lists.myitforum.com <mailto:scripting@lists.myitforum.com> 
Subject: RE: [scripting] Simple KIX Question

 

It's a function called "SubString" that's similar to the .NET String class'
SubString method. In the case of .NET, there are two method overloads:

 

PS C:\windows\system32> 'asdf'.Substring

 

OverloadDefinitions

-------------------

string Substring(int startIndex)

string Substring(int startIndex, int length)

 

In the first overload, it simply retrieves everything from startIndex to the
end of the string.

 

In the second overload, it retrieves everything from startIndex, for the
number of characters specified in the length parameter.

 

There isn't really any "math" going on here. Just simple string
manipulation. Using SubString for the purposes of parsing an IP address is a
really bad idea though, because the IP address is variable length. What if
the octet wasn't three characters long? I'd recommend using the Split()
method instead.

 

'10.11.12.13'.Split('.')[3]; # Yields the last octet, whose value is 13

 

Cheers,

Trevor Sullivan

 

From: listsad...@lists.myitforum.com <mailto:listsad...@lists.myitforum.com>
[mailto:listsad...@lists.myitforum.com] On Behalf Of Marcum, John
Sent: Monday, November 25, 2013 9:44 AM
To: Scripting List (scripting@lists.myITforum.com
<mailto:scripting@lists.myITforum.com> )
Subject: [scripting] Simple KIX Question

 

Can someone explain to me what this is doing? Specifically how does
"$mysubnet=SubStr($myaddress,5,3)" become "$mysubnet="200""? I assume it's
doing some math there or something????

 

 

   $myaddress=@ipaddress0

   $mysubnet=SubStr($myaddress,5,3)

;

   Select

;

; Local Office

                Case      $mysubnet="200"

                                $officelocation="BHM"

                                SetTime "\\SERVER02 <file:///\\SERVER02> "

                Case      $mysubnet="108"

                                $officelocation="BHM"

                                SetTime "\\SERVER02 <file:///\\SERVER02> "

 

  _____  

John Marcum
Sr. Desktop Architect

Bradley Arant Boult Cummings LLP

  _____  

 

 

  _____  


Confidentiality Notice: This e-mail is from a law firm and may be protected
by the attorney-client or work product privileges. If you have received this
message in error, please notify the sender by replying to this e-mail and
then delete it from your computer.

 

 

  _____  


Confidentiality Notice: This e-mail is from a law firm and may be protected
by the attorney-client or work product privileges. If you have received this
message in error, please notify the sender by replying to this e-mail and
then delete it from your computer.

 

  _____  


Confidentiality Notice: This e-mail is from a law firm and may be protected
by the attorney-client or work product privileges. If you have received this
message in error, please notify the sender by replying to this e-mail and
then delete it from your computer.

 



Reply via email to