mud409 Posted October 18, 2011 Posted October 18, 2011 (edited) Is there something like Array[-0] in AutoIt? IIRC that's how you obtain the final item of an array in Perl. Currently I'm using the below method to obtain the exe name to run. $full_path is a full path to an exe, which I don't know the number of sub directories to, so the location of the exe in the array changes, but is always the last one. $myArray= StringSplit($full_path, '\', 1) Dim $myArray $arraynum = UBound($myArray) $x = $arraynum - 1 $output = "" For $r = 0 to UBound($myArray,1) - 1 $output = $output & @LF For $c = 0 to UBound($myArray,2) - 1 $output = $output & $myArray[$r][$c] & " " Next Next $dir = StringReplace($full_path, $myArray[$x], "", 0, 1) ;remove file.exe from fullpath FileChangeDir($dir) Run(@ComSpec & " /c " & $myArray[$x] & " " & $CmdLine[1], "", @SW_HIDE) Edited October 18, 2011 by mud409
AdmiralAlkex Posted October 18, 2011 Posted October 18, 2011 UBound() returns the size of the array, so the last item is UBound() - 1. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
mud409 Posted October 18, 2011 Author Posted October 18, 2011 Doh! I already had everything, just had a chunk of useless code attached. Thanks!
GEOSoft Posted October 18, 2011 Posted October 18, 2011 $sFullPath = "C:\Some\Long.\Path\That Is \Rife\ with\.stupidity\file.exe" $sFldr = StringRegExpReplace($sFullPath, "^(.+\\).+$", "$1") FileChangeDir($sFldr) If you realloy need an array then $sFullPath = "C:\Some\Long.\Path\That Is \Rife\ with\.stupidity\file.exe" $aPath = StringRegExp($sFullPath, "^(.+\\)(.+)$", 1) If NOT @Error Then FileChangeDir($aPath[0] ;; contains the folder path Run($aPath[1]) ;; contains only the file name EndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
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