Jump to content

Recommended Posts

Thanks. What were the changes you made?


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

fixed a bug, I had forgotten the "C:Program FilesChat ToolsSkypeSkype.GUI.exe", so there was a bug in file with more than one "." (example Skype.G.U.I.exe ect ect)

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

Got it, thanks for that.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

just to give an example for Autoit v3.3.9.6 and after

; #FUNCTION# ====================================================================================================================
; Name...........: _PathSplitEx
; Description ...: Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing.
; Syntax.........: _PathSplitEx($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension)
; Parameters ....: $sFilePath  - The path to be split (Can contain a UNC server or drive letter)
;                 $sDrive    - String to hold the drive
;                 $sDir    - String to hold the directory
;                 $sFileName  - String to hold the file name
;                 $sExtension - String to hold the file extension
; Return values .: Success - Returns an array with 5 elements where 0 = original path 1 = drive, 2 = directory, 3 = filename, 4 = extension
; Author ........: DXRW4E
; Modified.......:
; Remarks .......: This function does not take a command line string. It works on paths, not paths with arguments.
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _PathSplitEx($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension)
    $sFilePath = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1)
    $sDrive = $sFilePath[1]
    $sDir = StringRegExpReplace($sFilePath[2], "\h*[\/\\]+\h*", StringLeft($sFilePath[2], 1) == "/" ? "\/" : "\\")
    $sFileName = $sFilePath[3]
    $sExtension = $sFilePath[4]
    Return $sFilePath
EndFunc

Ciao a tutti.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

How about a convenience function:

_PathPart($sFilePath,$sPart='p')

When $sFilePath='C:somedarnplacefile.ext.ext2'

$sPart:

p=C:somedarnplace

q=somedarnplace

d=C:somedarnplace

h=place

n=file

e=ext2

x=ext.ext2

f=file.ext.ext2

r=C:

D=C

Share this post


Link to post
Share on other sites

You easily create this yourself by wrapping around _PathSplit and _PathSplitEx.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

You easily create this yourself by wrapping around _PathSplit and _PathSplitEx.

 

Yes, and so can the next guy, and the next guy, and the next guy...

Makes you wonder why we have libraries at all ;)

Aren't there any convenience methods worth standardizing?

Share this post


Link to post
Share on other sites

Makes you wonder why we have libraries at all ;)

It makes me wonder why you just haven't created this yourself, instead of waiting for someone like me or DXRW4E to create it for you.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

I do not understand what's wrong with the _PathSplit(), example

#include <Array.au3>
#include <File.au3>

Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
Local $aPathSplit = _PathSplit("C:\some\darn\place\file.ext.ext2", $sDrive, $sDir, $sFilename, $sExtension)
_ArrayDisplay($aPathSplit, "_PathSplit of " & @ScriptFullPath)

;~ [0]|C:\some\darn\place\file.ext.ext2
;~ $sDrive = C:
;~ $sDir = \some\darn\place\
;~ $sFilename = file.ext
;~ $sExtension = .ext2

Local $p, $q, $d, $h, $n, $e, $f, $x, $r, $D2
;Local $sPart[10] = [$sDrive & $sDir, StringTrimLeft(StringTrimRight($sDir, 1), 1), StringTrimRight($sDrive & $sDir, 1), StringTrimRight(StringTrimLeft($sDir, StringInStr($sDir, "\", 1, -2)), 1), StringLeft($sFilename, StringInStr($sFilename, ".", 1) - 1), StringTrimLeft($sExtension, 1), $sFilename & $sExtension, StringTrimLeft($sFilename & $sExtension, StringInStr($sFilename & $sExtension, ".", 1, 1) - 1), $sDrive & "\", $sDrive]
;_ArrayDisplay($sPart)

$p = $sDrive & $sDir
$q = StringTrimLeft(StringTrimRight($sDir, 1), 1)
$d = StringTrimRight($p, 1)
$h = StringTrimLeft($d, StringInStr($d, "\", 1, -1))
$n = StringLeft($sFilename, StringInStr($sFilename, ".", 1) - 1)
$e = StringTrimLeft($sExtension, 1)
$f = $sFilename & $sExtension
$x = StringTrimLeft($f, StringInStr($f, ".", 1, 1) - 1)
$r = $sDrive & "\"
$D2 = $sDrive

ConsoleWrite($p & @LF & $q & @LF & $d & @LF & $h & @LF & $n & @LF & $e & @LF & $f & @LF & $x & @LF & $r & @LF & $D2 & @LF)

;~ >Running:(3.3.9.15):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Users\DXRW4E\Desktop\New AutoIt v3 Script (Beta).au3"
;~ --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
;~ C:\some\darn\place\
;~ some\darn\place
;~ C:\some\darn\place
;~ place
;~ file
;~ ext2
;~ file.ext.ext2
;~ .ext.ext2
;~ C:\
;~ C:
;~ +>00:34:31 AutoIt3.exe ended.rc:0
;~ >Exit code: 0    Time: 1.894

because it is impossible for the function to calculate each user's preference, some may want "C:aaabbbcccdddeee.ext.ext2.ext3" in

".ext.ext2.ext3"

".ext2"

"bbbcccddd"

"eee.ext.ext2"

ect ect

 

Ciao a tutti.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

Nothing is wrong, it splits the filepath into what can only be describes as known segments. ROOT|FOLDER|FILENAME|EXTENSION.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

good

#include <Array.au3>
#include <File.au3>
#include <FileOperations.au3>

$aFileList = _FO_FileSearch(@WindowsDir)
; $aFileList = _FO_FileSearch('C:\Documents and Settings')
;========================================================

Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
Local $aPathSplit
For $i = 1 To $aFileList[0]
    $aPathSplit = _PathSplit($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension)
    $aPathSplit1 = _PathSplit1($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension)
    For $j = 1 To 4
        If $aPathSplit[$j] <> $aPathSplit1[$j] Then MsgBox(0, 'Error', $aPathSplit[0] & @LF & @LF & $aPathSplit[$j] & @LF & @LF & $aPathSplit1[$j])
    Next
Next
MsgBox(0, 'Done', 'Done, files = ' & $aFileList[0])

;========================================================

Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
Local $aPathSplit

$timer1 = TimerInit()
For $i = 1 To $aFileList[0]
    $aPathSplit = _PathSplit1($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension) ; 3.3.9.16
Next
$timer1 = Round(TimerDiff($timer1), 2)

$timer2 = TimerInit()
For $i = 1 To $aFileList[0]
    $aPathSplit = _PathSplit($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension) ; 3.3.8.1
Next
$timer2 = Round(TimerDiff($timer2), 2)

MsgBox(0, "Done", _
        '$timer1 = ' & $timer1 & ' msec' & @LF & _
        '$timer2 = ' & $timer2 & ' msec')
;========================================================

Func _PathSplit1($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFilename, ByRef $sExtension)
    Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1)
    If @error Then ; This error should never happen.
        ReDim $aArray[5]
        $aArray[0] = $sFilePath
    EndIf
    $sDrive = $aArray[1]
    $tmp = StringLeft($aArray[2], 1) == "/"
    If $tmp Then
        $tmp = "\/"
    Else
        $tmp = "\\"
    EndIf
    $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", $tmp) ; StringRegExpReplace($aArray[2], "[\/\\]+\h*", "\" & ((StringLeft($aArray[2], 1) == "/") ? "/" : "\"))
    $sFilename = $aArray[3]
    $sExtension = $aArray[4]
    Return $aArray
EndFunc   ;==>_PathSplit1

Share this post


Link to post
Share on other sites

#include <Array.au3>
#include <File.au3>
#include <FileOperations.au3>

$aFileList = _FO_FileSearch(@WindowsDir)
; $aFileList = _FO_FileSearch('C:\Documents and Settings')
;========================================================

Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
Local $aPathSplit
For $i = 1 To $aFileList[0]
    $aPathSplit = _PathSplit($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension)
    $aPathSplit1 = _PathSplit1($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension)
    For $j = 1 To 4
        If $aPathSplit[$j] <> $aPathSplit1[$j] Then MsgBox(0, 'Error', $aPathSplit[0] & @LF & @LF & $aPathSplit[$j] & @LF & @LF & $aPathSplit1[$j])
    Next
Next
MsgBox(0, 'Done', 'Done, files = ' & $aFileList[0])

;========================================================

Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
Local $aPathSplit

$timer1 = TimerInit()
For $i = 1 To $aFileList[0]
    $aPathSplit = _PathSplit1($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension) ; 3.3.9.16
Next
$timer1 = Round(TimerDiff($timer1), 2)

$timer2 = TimerInit()
For $i = 1 To $aFileList[0]
    $aPathSplit = _PathSplit($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension) ; 3.3.9.16
Next
$timer2 = Round(TimerDiff($timer2), 2)

ConsoleWrite("Done " & _
        '$timer1 = ' & $timer1 & ' msec' & @LF & _
        '$timer2 = ' & $timer2 & ' msec' & @LF)
;========================================================

Func _PathSplit1($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFilename, ByRef $sExtension)
    Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1)
    If @error Then ; This error should never happen.
        ReDim $aArray[5]
        $aArray[0] = $sFilePath
    EndIf
    $sDrive = $aArray[1]
    $tmp = StringLeft($aArray[2], 1) == "/"
    If $tmp Then
        $tmp = "\/"
    Else
        $tmp = "\\"
    EndIf
    $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", $tmp) ; StringRegExpReplace($aArray[2], "[\/\\]+\h*", "\" & ((StringLeft($aArray[2], 1) == "/") ? "/" : "\"))
    $sFilename = $aArray[3]
    $sExtension = $aArray[4]
    Return $aArray
EndFunc   ;==>_PathSplit1
;~ >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "C:\Users\DXRW4E\Desktop\FileOperations_En\New AutoIt v3 Script (Beta).au3" /UserParams    
;~ +>18:22:51 Starting AutoIt3Wrapper v.2.1.2.16    Environment(Language:0409  Keyboard:00000409  OS:WIN_8/  CPU:X64 OS:X64)
;~ >Running AU3Check (3.3.9.16)  from:C:\Program Files (x86)\AutoIt3\Beta
;~ +>18:22:51 AU3Check ended.rc:0
;~ >Running:(3.3.9.16):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Users\DXRW4E\Desktop\FileOperations_En\New AutoIt v3 Script (Beta).au3"    
;~ --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
;~ Done $timer1 = 5574.09 msec
;~ $timer2 = 5075.09 msec
;~ +>18:23:17 AutoIt3.exe ended.rc:0
;~ >Exit code: 0    Time: 26.556

Hi AZJIO, who the point the speed ?, because _PathSplit is more faster ?

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

It works faster.

Func _PathSplit2($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt)
    Local $pos, $array[5] = [$szPath]
    Local $nPosForward = StringInStr($szPath, '/', 1, -1)
    Local $nPosBackward = StringInStr($szPath, '\', 1, -1)
    If $nPosForward >= $nPosBackward Then
        $pos = $nPosForward
    Else
        $pos = $nPosBackward
    EndIf
    $array[3] = StringTrimLeft($szPath, $pos) ; Имя с расширением
    $array[2] = StringLeft($szPath, $pos) ; Левая часть - путь к папке

    If StringMid($array[2], 2, 1) = ':' Then
        $array[1] = StringLeft($array[2], 2) ; drive
        $array[2] = StringTrimLeft($array[2], 2)
    ElseIf StringLeft($array[2], 2) = '\\' Then
        $array[2] = StringTrimLeft($array[2], 2) ; Trim the \\
        $pos = StringInStr($array[2], '\')
        If $pos = 0 Then $pos = StringInStr($array[2], '/')
        If $pos = 0 Then
            $array[1] = '\\' & $array[2]; Prepend the \\ we stripped earlier
            $array[2] = ''; Set to null because the whole path was just the UNC server name
        Else
            $pos -= 1
            $array[1] = '\\' & StringLeft($array[2], $pos) ; Prepend the \\ we stripped earlier
            $array[2] = StringTrimLeft($array[2], $pos)
        EndIf
    EndIf

    $pos = StringInStr($array[3], '.', 1, -1) ; Ищем справа "."
    If $pos Then ; Если имя содержит ".", то
        $pos -= 1
        $array[4] = StringTrimLeft($array[3], $pos) ; Отрезаем слева имя оставляя расширение
        $array[3] = StringLeft($array[3], $pos) ; Читаем слева имя до точки
    EndIf

    ; Set the strings and array to what we found
    $szDrive = $array[1]
    $szDir = $array[2]
    $szFName = $array[3]
    $szExt = $array[4]
    Return $array
EndFunc   ;==>_PathSplit

Share this post


Link to post
Share on other sites

_PathSplit is the best way, performs checks more secure, what's more it also repair the path, there are thousands of possible scenarios (which should normally never happen) it is not worth to name them all now, that the _PathSplit makes them more well, example

#include <Array.au3>
#include <File.au3>


Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
Local $aPathSplit, $sPath = "C:\aaa//bbb\\\ccc.exe"


$aPathSplit = _PathSplit2($sPath, $sDrive, $sDir, $sFilename, $sExtension) ; 3.3.9.16
_ArrayDisplay($aPathSplit)
ConsoleWrite('$sDrive = ' & $sDrive & @LF & _
        '$sDir = ' & $sDir & @LF & _
        '$sDir = ' & $sFilename & @LF & _
        '$sExtension = ' & $sExtension & @LF & @LF)

 $aPathSplit = _PathSplit($sPath, $sDrive, $sDir, $sFilename, $sExtension) ; 3.3.9.16
_ArrayDisplay($aPathSplit)

ConsoleWrite('$sDrive = ' & $sDrive & @LF & _
        '$sDir = ' & $sDir & @LF & _
        '$sDir = ' & $sFilename & @LF & _
        '$sExtension = ' & $sExtension & @LF & @LF)

;========================================================

Func _PathSplit2($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt)
    Local $pos, $array[5] = [$szPath]
    Local $nPosForward = StringInStr($szPath, '/', 1, -1)
    Local $nPosBackward = StringInStr($szPath, '\', 1, -1)
    If $nPosForward >= $nPosBackward Then
        $pos = $nPosForward
    Else
        $pos = $nPosBackward
    EndIf
    $array[3] = StringTrimLeft($szPath, $pos) ; Имя с расширением
    $array[2] = StringLeft($szPath, $pos) ; Левая часть - путь к папке

    If StringMid($array[2], 2, 1) = ':' Then
        $array[1] = StringLeft($array[2], 2) ; drive
        $array[2] = StringTrimLeft($array[2], 2)
    ElseIf StringLeft($array[2], 2) = '\\' Then
        $array[2] = StringTrimLeft($array[2], 2) ; Trim the \\
        $pos = StringInStr($array[2], '\')
        If $pos = 0 Then $pos = StringInStr($array[2], '/')
        If $pos = 0 Then
            $array[1] = '\\' & $array[2]; Prepend the \\ we stripped earlier
            $array[2] = ''; Set to null because the whole path was just the UNC server name
        Else
            $pos -= 1
            $array[1] = '\\' & StringLeft($array[2], $pos) ; Prepend the \\ we stripped earlier
            $array[2] = StringTrimLeft($array[2], $pos)
        EndIf
    EndIf

    $pos = StringInStr($array[3], '.', 1, -1) ; Ищем справа "."
    If $pos Then ; Если имя содержит ".", то
        $pos -= 1
        $array[4] = StringTrimLeft($array[3], $pos) ; Отрезаем слева имя оставляя расширение
        $array[3] = StringLeft($array[3], $pos) ; Читаем слева имя до точки
    EndIf

    ; Set the strings and array to what we found
    $szDrive = $array[1]
    $szDir = $array[2]
    $szFName = $array[3]
    $szExt = $array[4]
    Return $array
EndFunc   ;==>_PathSplit
>Running:(3.3.9.16):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Users\DXRW4E\Desktop\New AutoIt v3 Script (Beta).au3"    
;~ --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
;~ $sDrive = C:
;~ $sDir = \aaa//bbb\\\
;~ $sDir = ccc
;~ $sExtension = .exe

;~ $sDrive = C:
;~ $sDir = \aaa\bbb\
;~ $sDir = ccc
;~ $sExtension = .exe

so about the speed, if you takedisable in _PathSplit() the repair option, here

#include <Array.au3>
;#include <File.au3>
#include <FileOperations.au3>


$aFileList = _FO_FileSearch(@WindowsDir)
; $aFileList = _FO_FileSearch('C:\Documents and Settings')
;========================================================

Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
Local $aPathSplit
For $i = 1 To $aFileList[0]
    $aPathSplit = _PathSplit($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension)
    $aPathSplit1 = _PathSplit1($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension)
    For $j = 1 To 4
        If $aPathSplit[$j] <> $aPathSplit1[$j] Then MsgBox(0, 'Error', $aPathSplit[0] & @LF & @LF & $aPathSplit[$j] & @LF & @LF & $aPathSplit1[$j])
    Next
Next
MsgBox(0, 'Done', 'Done, files = ' & $aFileList[0])

;========================================================

Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
Local $aPathSplit

$timer1 = TimerInit()
For $i = 1 To $aFileList[0]
    $aPathSplit = _PathSplit1($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension) ; 3.3.9.16
Next
$timer1 = Round(TimerDiff($timer1), 2)

$timer2 = TimerInit()
For $i = 1 To $aFileList[0]
    $aPathSplit = _PathSplit2($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension) ; 3.3.9.16
Next
$timer2 = Round(TimerDiff($timer2), 2)

$timer3 = TimerInit()
For $i = 1 To $aFileList[0]
    $aPathSplit = _PathSplit($aFileList[$i], $sDrive, $sDir, $sFilename, $sExtension) ; 3.3.9.16
Next
$timer3 = Round(TimerDiff($timer3), 2)


ConsoleWrite("Done " & _
        '$timer1 = ' & $timer1 & ' msec' & @LF & _
        '$timer2 = ' & $timer2 & ' msec' & @LF & _
        '$timer3 = ' & $timer3 & ' msec' & @LF)
;========================================================

; #FUNCTION# ====================================================================================================================
; Author ........: Valik
; Modified.......: DXRW4E - Re-wrote to use a regular expression; guinness - Update syntax and structure.
; ===============================================================================================================================
Func _PathSplit($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension)
    Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1)
    If @error Then ; This error should never happen.
        ReDim $aArray[5]
        $aArray[0] = $sFilePath
    EndIf
    $sDrive = $aArray[1]
    $sDir = $aArray[2]
    ;$sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", StringLeft($aArray[2], 1) == "/" ? "\/" : "\\") ; StringRegExpReplace($aArray[2], "[\/\\]+\h*", "\" & ((StringLeft($aArray[2], 1) == "/") ? "/" : "\"))
    $sFileName = $aArray[3]
    $sExtension = $aArray[4]
    Return $aArray
EndFunc   ;==>_PathSplit


Func _PathSplit1($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFilename, ByRef $sExtension)
    Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1)
    If @error Then ; This error should never happen.
        ReDim $aArray[5]
        $aArray[0] = $sFilePath
    EndIf
    $sDrive = $aArray[1]
    $tmp = StringLeft($aArray[2], 1) == "/"
    If $tmp Then
        $tmp = "\/"
    Else
        $tmp = "\\"
    EndIf
    $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", $tmp) ; StringRegExpReplace($aArray[2], "[\/\\]+\h*", "\" & ((StringLeft($aArray[2], 1) == "/") ? "/" : "\"))
    $sFilename = $aArray[3]
    $sExtension = $aArray[4]
    Return $aArray
EndFunc   ;==>_PathSplit1

Func _PathSplit2($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt)
    Local $pos, $array[5] = [$szPath]
    Local $nPosForward = StringInStr($szPath, '/', 1, -1)
    Local $nPosBackward = StringInStr($szPath, '\', 1, -1)
    If $nPosForward >= $nPosBackward Then
        $pos = $nPosForward
    Else
        $pos = $nPosBackward
    EndIf
    $array[3] = StringTrimLeft($szPath, $pos) ; Имя с расширением
    $array[2] = StringLeft($szPath, $pos) ; Левая часть - путь к папке

    If StringMid($array[2], 2, 1) = ':' Then
        $array[1] = StringLeft($array[2], 2) ; drive
        $array[2] = StringTrimLeft($array[2], 2)
    ElseIf StringLeft($array[2], 2) = '\\' Then
        $array[2] = StringTrimLeft($array[2], 2) ; Trim the \\
        $pos = StringInStr($array[2], '\')
        If $pos = 0 Then $pos = StringInStr($array[2], '/')
        If $pos = 0 Then
            $array[1] = '\\' & $array[2]; Prepend the \\ we stripped earlier
            $array[2] = ''; Set to null because the whole path was just the UNC server name
        Else
            $pos -= 1
            $array[1] = '\\' & StringLeft($array[2], $pos) ; Prepend the \\ we stripped earlier
            $array[2] = StringTrimLeft($array[2], $pos)
        EndIf
    EndIf

    $pos = StringInStr($array[3], '.', 1, -1) ; Ищем справа "."
    If $pos Then ; Если имя содержит ".", то
        $pos -= 1
        $array[4] = StringTrimLeft($array[3], $pos) ; Отрезаем слева имя оставляя расширение
        $array[3] = StringLeft($array[3], $pos) ; Читаем слева имя до точки
    EndIf

    ; Set the strings and array to what we found
    $szDrive = $array[1]
    $szDir = $array[2]
    $szFName = $array[3]
    $szExt = $array[4]
    Return $array
EndFunc   ;==>_PathSplit
;~ >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "C:\Users\DXRW4E\Desktop\FileOperations\FileOperations_En\New AutoIt v3 Script (Beta).au3" /UserParams    
;~ +>00:19:20 Starting AutoIt3Wrapper v.2.1.2.16    Environment(Language:0409  Keyboard:00000409  OS:WIN_8/  CPU:X64 OS:X64)
;~ >Running AU3Check (3.3.9.16)  from:C:\Program Files (x86)\AutoIt3\Beta
;~ +>00:19:20 AU3Check ended.rc:0
;~ >Running:(3.3.9.16):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Users\DXRW4E\Desktop\FileOperations\FileOperations_En\New AutoIt v3 Script (Beta).au3"    
;~ --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
;~ Done $timer1 = 5333.88 msec
;~ $timer2 = 4394.69 msec
;~ $timer3 = 3362.21 msec
;~ +>00:19:48 AutoIt3.exe ended.rc:0
;~ >Exit code: 0    Time: 28.779

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

Because it did not cost anything as you can see _PathSplit is only 7 line, however is only _PathSplit() everything else about Path (how to say in an Microsoft official way) is in AutoIt help WinApiEx ShellPath Management (#include <WinAPIShPath.au3>.)

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

A year ago, when I tested _FO_PathSplit, then the regular expression was slower than the string functions. But I returned the 3 elements (380 msec). Apparently the number of elements affect the speed of regular expressions

Because it did not cost anything

You consider, what 30% it anything? 980 -> 650
If this is the correct path to the file, it returns correctly. If this is not the correct path to the file, whether the user wanted to correct it?

Edited by AZJIO

Share this post


Link to post
Share on other sites

to check if the path is correct and repair the path it costs the same time ehhh, so better to perform the repair directly, StringRegExp always return ok, so why not take the opportunity to repair the path ;)

as mentioned before are things that normally should not happen ever, but if I'm not mistaken many Windows Api and AutoIt native function (FileExists and FileRead ect ect), perform repair of the path before proceeding ect ect, so how to say is not out of place that _PathSplit try to repair the path, I think it's better this way because being a function which is the default is better to take all precautions, however it remains a choice hmmm I do not know

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Colduction
      Hi dear friends!, i'm sorry for creating a new thread (a new problem), i have over than 9 lists that i want to combine them to be this (in this example, there are 3 test files):


      I've written a little code for splitting main information, but i really confused how to make results as "Output.txt", here is that code:
       
      $sRegex_1 = StringRegExp(FileRead("1.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3) $sRegex_2 = StringRegExp(FileRead("2.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3) $sRegex_3 = StringRegExp(FileRead("3.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3) For $i = 0 To UBound($sRegex_1) - 1 ConsoleWrite($sRegex_1[$i] & @CRLF) For $j = 0 To UBound($sRegex_2) - 1 ConsoleWrite($sRegex_2[$j] & @CRLF) For $k = 0 To UBound($sRegex_3) - 1 ConsoleWrite($sRegex_3[$k] & @CRLF) Next Next Next  
    • By nacerbaaziz
      hello evrybody
      here is an example about how to split your texts using a delimiter with the ability to select how much of delimiters shows in each colum  with $i_number
      e.g
      you have a long text and you want to split it in an array
      that evry colum have a number (n) of lines
      i made a function that do that for you
      just call it with a three params
      $s_text
      your text
      $i_number
      the number that you want to put in each col
      $s_siparator
      the siparator
      default is "|"
      here is the function with example
      i hope that it will be useful for you
       
      ****
       
      #include <Array.au3> $s_txt = "some text1some text2|some text3|some text4|some text5|some text6" $array = splitText($s_txt, 2) _ArrayDisplay($array) Func splitText($s_text, $i_number, $s_siparator = "|") Local $a_TXT = StringSplit($s_text, $s_siparator) Local $a_Return[$a_TXT[0] + 1] If ($a_TXT[0] <= $i_number) Or ($i_number <= 0) Then ReDim $a_Return[2] $a_Return[0] = 1 $a_Return[1] = $s_text Return $a_Return EndIf Local $i_Processed = 1, $i_arrayProcessed = 1 Do For $i = $i_Processed To ($i_Processed + $i_number) - 1 If ($a_TXT[0] < $i) Then ExitLoop If Not ($a_Return[$i_arrayProcessed]) Then $a_Return[$i_arrayProcessed] = $a_TXT[$i] Else $a_Return[$i_arrayProcessed] &= $s_siparator & $a_TXT[$i] EndIf $i_Processed += 1 Next $i_arrayProcessed += 1 Until ($a_TXT[0] < $i_Processed) ReDim $a_Return[$i_arrayProcessed] $a_Return[0] = $i_arrayProcessed - 1 Return $a_Return EndFunc ;==>splitText
      accept my greetings
      thanks to
      @Dan_555
      for his notes
       
    • By MesterPerfect
      good morning
      this is the first post here in the autoit forums
      i hope that you can help me in my problem
      i have a JSON encoded
      it a map of my forums
      where i want to make a treeview that have the same type of map
      e.g
      a system (as category)
      windows (as sub category)
      software (as an child item in the windows category)
      .....
      i don't know how to do that
      so, i know that i can do that using the json functions
      but i need your help about how we can do it as the type that i told you
      by the way i need to put the sub info for each item in an array that give me the ability to manage my items
      e.g
      can post thread
      can reply
      message cound ...
      you just give me a small example and i can continue.
      am sorry if this against the rules of the forum.
      but i realy searched a lot but i couldn't
      i hope some one give me the way.
      thank you very much in advance
       
      here is the link of json forum
      https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn/
      and here is my encoded json file
       
      { "tree_map": { "0": [ 1, 5, 6, 7 ], "1": [ 2 ], "2": [ 4 ], "5": [ 3 ], "6": [ 8 ], "8": [ 9, 10 ] }, "nodes": [ { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 1, "node_id": 1, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Main category", "type_data": {} }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 2, "node_name": null, "node_type_id": "Forum", "parent_node_id": 1, "title": "Main forum", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" }, { "node_id": 2, "title": "Main forum", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 4, "node_name": null, "node_type_id": "Forum", "parent_node_id": 2, "title": "my forums1", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 2, "node_id": 5, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Perfect", "type_data": {} }, { "breadcrumbs": [ { "node_id": 5, "title": "Perfect", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 2, "node_id": 3, "node_name": null, "node_type_id": "Forum", "parent_node_id": 5, "title": "ahmed", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 3, "node_id": 6, "node_name": null, "node_type_id": "Forum", "parent_node_id": 0, "title": "autoit", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 8, "node_name": null, "node_type_id": "Forum", "parent_node_id": 6, "title": "examples", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 9, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "GUI", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 31, "node_id": 10, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "windowEX", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 4, "node_id": 7, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "vbs", "type_data": {} } ] }  
    • By Tosyk
      Hi,
      Please help me to change metasymbol line. Right now I have this condition code:
      If StringInStr($_sName, 'TEXT ') Then $_sName = StringRegExpReplace($_sName, '(^.*)\TEXT (.*)$', '$2') $_sName = StringRegExpReplace($_sName, '(^.*)\ (.*)$', '$1') If Not CheckIsSave_($_sName) Then It work fine with this text file and finds each line which start from 'TEXT':
      Material B7E671143D244B ==================================== TEXT 2F3139D816C34D 1 TEXT B6A968EF2505A2 1 TEXT 35206697A04F91 1 TEXT EB485AF490D83D 1 TEXT 0DAB42294BD9B3 1 TEXT 3D6525BEE360E1 0 Material D6906B886B06E3 ==================================== TEXT 0CCECCCCFB62AE 1 TEXT 1E14CB29AB43F0 1 TEXT FB7F0DCE9B5950 1 But I have a new text file now the lines of which now are start with 0:, 1: and so on:
      sm_0 --------------- 0: dummy_gray 1: c_com_socksa_mt 2: c_com_socksa_tn 3: dummy_white 4: default_z 5: dummy_nmap 6: --- 7: --- sm_1 --------------- 0: c_com_prisoner_shoes_di 1: c_com_prisoner_shoes_mt 2: c_com_prisoner_shoes_tn 3: dummy_white 4: default_z 5: c_com_leatherb_rt 6: --- 7: --- how to change (or add) the condition code above to work with new text file?
      I'm trying to change this script: http://autoit-script.ru/threads/poisk-fajlov-rekursivno-po-dannomu-spisku.26970/post-148646
       
×
×
  • Create New...