Jump to content

Array[-0]?


mud409
 Share

Recommended Posts

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 by mud409
Link to comment
Share on other sites

$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!"

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...