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]
On Behalf Of Marcum, John
Sent: Monday, November 25, 2013 9:44 AM
To: Scripting List (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.

 



Reply via email to