rootx Posted May 14, 2014 Share Posted May 14, 2014 (edited) Hello friends, I need to extrapolate the max value from this cicle. Object: remove everything before the last backslash to have "img" folder without the path Example() Func Example() Local $sText = "C:folder1folder2img" Local $aArray = StringSplit($sText, '', $STR_ENTIRESPLIT) For $i = 1 To $aArray[0] MsgBox($MB_SYSTEMMODAL, "", "$aArray[" & $i & "] - " & $aArray[$i]) Next EndFunc Tanks Edited May 14, 2014 by rootx Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 14, 2014 Moderators Share Posted May 14, 2014 (edited) Do you mean the total indexes in the array? You would just look at the value of $aArray[0]. Example() Func Example() Local $sText = "C:\folder1\folder2\img" Local $aArray = StringSplit($sText, '\', 1) MsgBox(0, "", $aArray[0]) EndFunc Edited May 14, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
czardas Posted May 14, 2014 Share Posted May 14, 2014 (edited) $STR_ENTIRESPLIT is not needed, because the delimiter is a single character. You can also get the folder name from the path by using StringRight and StringInStr - searching from the right to get the final backslash character's position. Edited May 14, 2014 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 14, 2014 Share Posted May 14, 2014 (edited) Local $sText = "C:\folder1\folder2\img" Local $sText1 = "C:\folder1\img" Local $aArray = StringSplit($sText, '\') Local $aArray1 = StringSplit($sText1, '\') Local $var = $aArray[0], $var1 = $aArray1[0] ConsoleWrite($aArray[$var] & @LF & $aArray1[$var1] & @LF) Edited May 14, 2014 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 14, 2014 Share Posted May 14, 2014 oops, I had $sText1 in both StringSplit lines. I edited my post. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
UEZ Posted May 14, 2014 Share Posted May 14, 2014 Here some variants which came to my mind: #include <File.au3> Local $sText = "C:\folder1\folder2\img" ;variant 1 ConsoleWrite("1: " & StringRight($sText, StringLen($sText) - StringInStr($sText, "\", 0, -1)) & @CRLF) ;variant 2 ConsoleWrite("2: " & StringTrimLeft($sText, StringInStr($sText, "\", 0, -1)) & @CRLF) ;variant 3 ConsoleWrite("3: " & StringMid($sText, StringInStr($sText, "\", 0, -1) + 1) & @CRLF) ;variant 4 ConsoleWrite("4: " & StringRegExpReplace($sText, "^.*\\(.*)$", "$1") & @CRLF) ;variant 5 Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = "" Local $aPathSplit = _PathSplit($sText, $sDrive, $sDir, $sFilename, $sExtension) ConsoleWrite("5: " & $aPathSplit[3] & @CRLF) Br, UEZ czardas 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
rootx Posted May 15, 2014 Author Share Posted May 15, 2014 (edited) Thanks everyone, UEZ... wonderfully great answer. My solution ;set path Local $imgfolder = FileSelectFolder("Inserisci il nome della cartella che contiene le immagini", "", "", @ScriptDir) ;write value to init.txt FileWrite($file,(StringRight($imgfolder, StringLen($imgfolder) - StringInStr($imgfolder, "", 0, -1)))) works fine. Edited May 15, 2014 by rootx Link to comment Share on other sites More sharing options...
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