MadBoy Posted March 2, 2006 Posted March 2, 2006 Hello. I got little problem which i couldnt resolve by myself. I had little array that i wanted to convert to string but i wanted delimter to be " \s " instead of " " or TAB. Couldn't get it to work, always was empty string. When i used it with " " worked fine. Thanks In advance This works: Dim $sArrayString = _ArrayToString( $array," ",1) MsgBox( 4096, "_ArrayToString() Test", $sArrayString ) This doesn't: Dim $sArrayString = _ArrayToString( $array," \s ",1) MsgBox( 4096, "_ArrayToString() Test", $sArrayString ) My little company: Evotec (PL version: Evotec)
GrungeRocker Posted March 2, 2006 Posted March 2, 2006 (edited) what aboutDim $sArrayString = _ArrayToString( $array,"\s",1)? Edited March 2, 2006 by Analritter [font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]
BigDod Posted March 2, 2006 Posted March 2, 2006 Quote straight from help fileRemarksThis function is the opposite of the StringSplit function with the extension of being able to take a subset of all of the elements and placing just that subset into the string.Since this function is the inverse of the StringSplit function, the delimiter can't be larger than 1 character in length. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother
GrungeRocker Posted March 2, 2006 Posted March 2, 2006 Quote straight from help file i thought it was 2 chars... [font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]
MadBoy Posted March 2, 2006 Author Posted March 2, 2006 Bah, must have missed it when reading :/ Anyway, is there a way to go around this ? My little company: Evotec (PL version: Evotec)
Moderators SmOke_N Posted March 2, 2006 Moderators Posted March 2, 2006 Bah, must have missed it when reading :/ Anyway, is there a way to go around this ?Do you have to have \s as the delimeter? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Developers Jos Posted March 2, 2006 Developers Posted March 2, 2006 Bah, must have missed it when reading :/ Anyway, is there a way to go around this ?expandcollapse popupFunc _ArrayToString(Const ByRef $avArray, $sDelim, $iStart = 0, $iEnd = 0) ; Declare local variables. Local $iCntr = 0, $iUBound = 0, $sResult = "" ; If $avArray is an array then set var for efficiency sake. If (IsArray($avArray)) Then $iUBound = UBound($avArray) - 1 EndIf If $iEnd = 0 Then $iEnd = $iUBound ; Check for parameter validity. Select Case (Not IsArray($avArray)) SetError(1) Return "" Case( ($iUBound + 1) < 2 Or UBound($avArray, 0) > 1) SetError(2) Return "" Case (Not IsInt($iStart)) SetError(3) Return "" Case (Not IsInt($iEnd)) SetError(5) Return "" Case (Not IsString($sDelim)) SetError(7) Return "" Case ($sDelim = "") SetError(8) Return "" ;Case (StringLen($sDelim) > 1) ; SetError(9) ; Return "" Case ($iStart = -1 And $iEnd = -1) $iStart = 0 $iEnd = $iUBound Case ($iStart < 0) SetError(4) Return "" Case ($iEnd < 0) SetError(6) Return "" EndSelect ; Make sure that $iEnd <= to the size of the array. If ($iEnd > $iUBound) Then $iEnd = $iUBound EndIf ; Combine the elements into the string. For $iCntr = $iStart To $iEnd $sResult = $sResult & $avArray[$iCntr] If ($iCntr < $iEnd) Then $sResult = $sResult & $sDelim EndIf Next SetError(0) Return $sResult EndFunc ;==>_ArrayToString SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
seandisanti Posted March 2, 2006 Posted March 2, 2006 Bah, must have missed it when reading :/ Anyway, is there a way to go around this ?easiest way would probably be a quick 'for' loop through the array that concatenates a "\" to the end of each element (except the 0 element if that's your count), then use "s" as your delimiter...
MadBoy Posted March 3, 2006 Author Posted March 3, 2006 @JDEB - a lot of code for small proggie like mine @SMOKE - well i have to use /s as SecureCRT.EXE command line uses /s as session trigger so i need to use it like SecureCRT.EXE /s session1 /s session2 /session3 and as it takes the sessions names from .ini file: secure_sessions_names i had to 'divide' it somehow I solved it by doing 10 If's but that made it a bit long and i can't set more then 10 sessions (not like i will but for better use If FileExists($secure_exe) Then If $array[0] = 1 Then Run($secure_exe & " /s " & $array[1] ) If $array[0] = 2 Then Run($secure_exe & " /s " & $array[1] & " /s " & $array[2]) and so on up to 10. @cameronsdad - been going thru my mind to make all kind of loops well it's not a biggy anyway atm. My little company: Evotec (PL version: Evotec)
seandisanti Posted March 3, 2006 Posted March 3, 2006 @JDEB - a lot of code for small proggie like mine @SMOKE - well i have to use /s as SecureCRT.EXE command line uses /s as session trigger so i need to use it like SecureCRT.EXE /s session1 /s session2 /session3 and as it takes the sessions names from .ini file: secure_sessions_names i had to 'divide' it somehow I solved it by doing 10 If's but that made it a bit long and i can't set more then 10 sessions (not like i will but for better use If FileExists($secure_exe) Then If $array[0] = 1 Then Run($secure_exe & " /s " & $array[1] ) If $array[0] = 2 Then Run($secure_exe & " /s " & $array[1] & " /s " & $array[2]) and so on up to 10. @cameronsdad - been going thru my mind to make all kind of loops well it's not a biggy anyway atm.For $x = 0 to Ubound($array) $array[$x] = $array[$x] & "/" Next $newstring = _ArrayToString($array,"s") or if you want to have it like: element /s element then it would just be: For $x = 0 to Ubound($array) $array[$x] = " " & $array[$x] & " /" Next $newstring = _ArrayToString($array,"s")
Developers Jos Posted March 4, 2006 Developers Posted March 4, 2006 @JDEB - a lot of code for small proggie like mine Nope... its the original UDF with the lines commented that are giving the limitation of one character... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
MadBoy Posted March 4, 2006 Author Posted March 4, 2006 Nope... its the original UDF with the lines commented that are giving the limitation of one character... @JDEB - i am not yet at that stage to fully understand UDF code ;p So i took it as it was solution to my problem @CameronSDAD tnx My little company: Evotec (PL version: Evotec)
seandisanti Posted March 5, 2006 Posted March 5, 2006 @JDEB - i am not yet at that stage to fully understand UDF code ;p So i took it as it was solution to my problem @CameronSDAD tnxno problem. always glad to help
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now