#156797 - 2006-02-07 04:12 PM
VBS "MID" equivalent
|
DrShark
Fresh Scripter
Registered: 2005-07-13
Posts: 33
|
All,
can someone give a hint and tell me the best KIX equivalent for the VBScript "MID"!?
Best Regards
|
|
Top
|
|
|
|
#156799 - 2006-02-07 04:39 PM
Re: VBS "MID" equivalent
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4567
Loc: USA
|
|
|
Top
|
|
|
|
#156800 - 2006-02-07 05:00 PM
Re: VBS "MID" equivalent
|
DrShark
Fresh Scripter
Registered: 2005-07-13
Posts: 33
|
Then someone may help me with this function - I translated it to KIX but it raises an error and does not give back the desired value.
Code:
$strTest="LDAP://CN=DrShark,OU=1,OU=2,OU=3,OU=Test,DC=test,DC=dom" $TestOU = getFirstOU($strTest) MessageBox($TestOU,"")
Function getFirstOU($LDAP)
If instr(UCase($LDAP),"OU=")>0 $strStringAnfang=instr(UCase($LDAP),"OU=")+3 Else $strStringAnfang=instr(UCase($LDAP),"DC=")+3 EndIf
$strStringEnde=instr(UCase($LDAP),",") $strStringLength=($strStringEnde-$strStringAnfang)
$temp=Substr($LDAP,$strStringAnfang,$strStringLength)
getFirstOU=$temp
EndFunction
|
|
Top
|
|
|
|
#156801 - 2006-02-07 05:09 PM
Re: VBS "MID" equivalent
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
$strStringEnde=instr(UCase($LDAP),",")
does not do what you want. at least I believe so. would guess you are after something like: Code:
$strTest="LDAP://CN=DrShark,OU=1,OU=2,OU=3,OU=Test,DC=test,DC=dom" $TestOU = getFirstOU($strTest) MessageBox($TestOU,"")
Function getFirstOU($LDAP)
If instr(UCase($LDAP),"OU=")>0 $LDAP = substr($LDAP, instr(UCase($LDAP),"OU=")+3) Else $LDAP = substr($LDAP, instr(UCase($LDAP),"DC=")+3) EndIf getFirstOU= substr($LDAP,1, instr(ucase($LDAP),",") - 1) EndFunction
_________________________
!download KiXnet
|
|
Top
|
|
|
|
#156802 - 2006-02-07 05:20 PM
Re: VBS "MID" equivalent
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
Golfed: Break ON $DN="LDAP://CN=DrShark,OU=1,OU=2,OU=3,OU=Test,DC=test,DC=dom" $ = Split(Split(Split($DN,'cn=')[1],',dc=')[0],',ou=')[1] $ ?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
|
Top
|
|
|
|
#156803 - 2006-02-07 05:26 PM
Re: VBS "MID" equivalent
|
DrShark
Fresh Scripter
Registered: 2005-07-13
Posts: 33
|
I am after the coplete string so after calling the function it should be someting like this: "OU=1,OU=2,OU=3,OU=Test,DC=test,DC=dom".
But when using your suggestion it says: Missing "(" in line 12...
|
|
Top
|
|
|
|
#156805 - 2006-02-07 06:38 PM
Re: VBS "MID" equivalent
|
DrShark
Fresh Scripter
Registered: 2005-07-13
Posts: 33
|
Quote:
so, if you are after the whole string, what you try to accomplish with: $strStringEnde=instr(UCase($LDAP),",")
I just copy&pasted the code from some other vbs scripts where I need it and I am now trying to convert it to KiX. 
If you see some improvements or code that is obsolet let me know. I only need this string mentioned above for further steps.
|
|
Top
|
|
|
|
#156806 - 2006-02-07 07:48 PM
Re: VBS "MID" equivalent
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
OK, if you want the Right() of it... (not golfed) Break ON $DN="LDAP://CN=DrShark,OU=1,OU=2,OU=3,OU=Test,DC=test,DC=dom" $Len = Len($DN) $Len ? $InStr = InStr($DN,',ou=') $InStr ? $ = Right($DN,$Len-$InStr) $ ?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
|
Top
|
|
|
|
#156809 - 2006-02-08 12:10 AM
Re: VBS "MID" equivalent
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
les, yes. $DN="LDAP://CN=DrShark,OU=1,OU=2,OU=3,OU=Test,DC=test,DC=dom" $ = substr($DN,1+InStr($DN,',ou='))
_________________________
!download KiXnet
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 641 anonymous users online.
|
|
|