-
Posts
27 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
Rofellos's Achievements

Seeker (1/7)
4
Reputation
-
ahmeddzcom reacted to a post in a topic: Get the file name and the file directory from a file path
-
Marcelos reacted to a post in a topic: Get the file name and the file directory from a file path
-
GajjarTejas reacted to a post in a topic: Run, RunWait... Run anything is not working for cmdline
-
RedneckTech reacted to a post in a topic: Run, RunWait... Run anything is not working for cmdline
-
How do I detect and handle selection changes on a listbox??? Please, this is urgent!
-
When I try to acess a file I get a "sharing violation" error message. It's probably caused by my antivirus (because the file is recently created). Can I check if a file is been used by another aplication or force that its closes?
-
Get the file name and the file directory from a file path
Rofellos replied to Rofellos's topic in AutoIt Example Scripts
Yes, thanks! -
Get the file name and the file directory from a file path
Rofellos replied to Rofellos's topic in AutoIt Example Scripts
Yes, but with _PathSplit you have to concatenate the items of the array to get de full directory every time. And I use it a lot. So I made a function to reduce the work. _PathSplit and _PathSplitByRegExp are actually much more versatile. But some times I need something more specific. -
These functions are very useful if you got a file path and want the name or the directory of the file. ; #FUNCTION# ====================================================================================================== ; Name...........: GetDir ; Description ...: Returns the directory of the given file path ; Syntax.........: GetDir($sFilePath) ; Parameters ....: $sFilePath - File path ; Return values .: Success - The file directory ; Failure - -1, sets @error to: ; |1 - $sFilePath is not a string ; Author ........: Renan Maronni <renanmaronni@hotmail.com> ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ================================================================================================================== Func GetDir($sFilePath) Local $aFolders = StringSplit($sFilePath, "\") Local $iArrayFoldersSize = UBound($aFolders) Local $FileDir = "" If (Not IsString($sFilePath)) Then Return SetError(1, 0, -1) EndIf $aFolders = StringSplit($sFilePath, "\") $iArrayFoldersSize = UBound($aFolders) For $i = 1 To ($iArrayFoldersSize - 2) $FileDir &= $aFolders[$i] & "\" Next Return $FileDir EndFunc ;==>GetDir ; #FUNCTION# ====================================================================================================== ; Name...........: GetFileName ; Description ...: Returns the file name of the given file path ; Syntax.........: GetFileName($sFilePath) ; Parameters ....: $sFilePath - File path ; Return values .: Success - The file name ; Failure - -1, sets @error to: ; |1 - $sFilePath is not a string ; Author ........: Renan Maronni <renanmaronni@hotmail.com> ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =================================================================================================================== Func GetFileName($sFilePath) Local $aFolders = "" Local $FileName = "" Local $iArrayFoldersSize = 0 If (Not IsString($sFilePath)) Then Return SetError(1, 0, -1) EndIf $aFolders = StringSplit($sFilePath, "\") $iArrayFoldersSize = UBound($aFolders) $FileName = $aFolders[($iArrayFoldersSize - 1)] Return $FileName EndFunc ;==>GetFileName
-
Using functions as _FileListToArray or StringSplit, you may get an array with several duplicate or blank entries. This function removes all duplicate and blank entries, and return a new array (without duplicate and blank entries). It also updates the element of index 0 (number of entries). * It needs to #include <Array.au3> ; #FUNCTION# ====================================================================================================== ; Name...........: ArrayStripDuplicate ; Description ...: Strips the duplicate items and blank space from given array ; Syntax.........: ArrayStripDuplicate($aArray) ; Parameters ....: $aArray - Input array ; Return values .: Success - The new array ; Failure - -1, sets @error to: ; |1 - $aArray is not an array ; |2 - $aArray is not a 1 dimensional array ; Author ........: Renan Maronni <renanmaronni@hotmail.com> ; Modified.......: ; Remarks .......: It needs the #include <Array.au3> ; Related .......: ; Link ..........: ; Example .......: ; ================================================================================================================= Func ArrayStripDuplicate($aArray) Local $aNewArray[1] Local $iArraySize = UBound($aArray) If (Not IsArray($aArray)) Then Return SetError(1, 0, -1) EndIf If (UBound($aArray, 0) <> 1) Then Return SetError(2, 0, -1) EndIf For $i = 1 To ($iArraySize - 1) If (_ArraySearch($aNewArray, $aArray[$i]) = -1) Then _ArrayAdd($aNewArray, $aArray[$i]) EndIf Next $aNewArray[0] = UBound($aNewArray) - 1 Return $aNewArray EndFunc ;==>ArrayStripDuplicate
-
Karina. The name is Karina.
-
The idea was to use StringSplit() to make a function. Not constantly use StringSplit() over the source code. I didn't know _ArrayAdd, thanks.
-
Thanks shanet , I fixed it. That works too.
-
In AutoIt, you can not create a dynamic array, you have to specify the length of the array when you create it. One way to create dynamic arrays is create a dynamic string, where substrings are separated by a charactere like "\", and then, use StringSplit. $sString = "" $sString &= "Frist String" & "\" $sString &= "Second String" & "\" $sString &= "Third String" & "\" $aArray = StringSplit( $sString , "\" ) ; $aArray[0] is number of substrings, in this case is 4. ; $aArray[1] is the string "Frist String" ; $aArray[2] is the string "Second String" ; $aArray[3] is the string "Third String" ; $aArray[4] is the string ""
-
Almost all the functions in GuiTreeView.au3 that return the item handle, requests the item handle as parameter. It makes no sense to me.... ; #FUNCTION# ==================================================================================================================== ; Name...........: _GUICtrlTreeView_GetItemByIndex ; Description ...: Retrieve a item by its position in the list of child items ; Syntax.........: _GUICtrlTreeView_GetItemByIndex($hWnd, $hItem, $iIndex) ; Parameters ....: $hWnd - Handle to the control ; $hItem - Handle to the item ; $iIndex - Zero based index of item in the list of child items ; Return values .: Success - Handle of the item ; Failure - 0 ; Author ........: Paul Campbell (PaulIA) ; Modified.......: ; Remarks .......: ; Related .......: _GUICtrlTreeView_Index ; Link ..........: ; Example .......: Yes ; ===============================================================================================================================
-
Аctivate and choose elements menu in ControlTreeView
Rofellos replied to achumagin's topic in AutoIt General Help and Support
There some useful user defined functions on GuiTreeView.au3. Take a look on: _GUICtrlTreeView_ClickItem _GUICtrlTreeView_GetItemHandle -
Anyone, please...
-
How can I manipulate this control: SPR32X60_SpreadSheet? Can I use Excel commands? Thanks.