Followers 0

# Array file and dir list

## 35 posts in this topic

So, because I have folders at work that include folders and no files the first code did not work, but because it continues the loop either way in the second code it worked?

This is true.

Also if the include is fixed it would be a good idea to change the if statement to something like:

If (Not IsArray($FileList) Or @error) Then Don't argue with an idiot; people watching may not be able to tell the difference. #### Share this post ##### Link to post ##### Share on other sites This is true. Also if the include is fixed it would be a good idea to change the if statement to something like: If (Not IsArray($FileList) Or @error) Then
I am not sure I understand the difference between the function that you posted and the If statement - looks like it does the same thing? Only @error does not contain a value and the grouping is different - does it matter?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

# Ternary operator

##### Share on other sites

I am not sure I understand the difference between the function that you posted and the If statement - looks like it does the same thing? Only @error does not contain a value and the grouping is different - does it matter?

yes it will matter, if you check @error to be equal to 1 only you are going to have problems.

Don't argue with an idiot; people watching may not be able to tell the difference.

##### Share on other sites

yes it will matter, if you check @error to be equal to 1 only you are going to have problems.

got you - I will continue over the weekend

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

# Ternary operator

##### Share on other sites

Why does this not work? In the code everything works but the part that I am asking about. Not sure if I code it right, but the first msgbox() shows the file, how come it does not read the second line or anyline?

#include <GuiConstants.au3>
#include <GuiListView.au3>

#Include <File.au3>
#Include <Array.au3>

Dim $Btn_TestScroll,$Btn_Exit, $msg,$Status, $i,$line2

GUICreate("ListView Scroll", 392, 322)

$listview = GUICtrlCreateListView("URL List|URL", 40, 30, 310, 149) _GUICtrlListViewSetColumnWidth($listview, 0, $LVSCW_AUTOSIZE_USEHEADER)$Btn_TestScroll = GUICtrlCreateButton("Scroll Test", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)$Status = GUICtrlCreateLabel("Remember items are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN,$SS_CENTER))

GUISetState()

_LoadListView($listview) While 1$msg = GUIGetMsg()
Select
Case $msg =$GUI_EVENT_CLOSE Or $msg =$Btn_Exit
ExitLoop
Case $msg =$Btn_TestScroll
For $i = 10 To 50 Step 10 _GUICtrlListViewScroll($listview, 0, $i) Sleep(500) _GUICtrlListViewScroll($listview, 0, $i - ($i * 2))
Sleep(500)
Next
EndSelect
WEnd
Exit

Func _LoadListView(ByRef $listview)$dirList = _FileListToArray(@FavoritesDir, '*', 2)
If (Not IsArray($dirList)) and (@error = 1) Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf$fileListurl = _FileListToArray(@FavoritesDir, '*.url', 1)
If (Not IsArray($fileListurl)) and (@error = 1) Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf For$test3 = 1 To $fileListurl[0] ; Why does this not work? MsgBox(0,$fileListurl[$test3], "") FileOpen($fileListurl[$test3], 0)$line2 = FileReadLine($fileListurl[$test3], 2)
MsgBox(0, "", $line2) FileClose($fileListurl[$test3]) ; above code does not work GUICtrlCreateListViewItem($fileListurl[$test3] & "|" & "$line2", $listview) Next For$TEST1 = 1 To $dirList[0] GUICtrlCreateListViewItem($dirList[$TEST1],$listview)

$FileList = _FileListToArray(@FavoritesDir & "\" &$dirList[$TEST1], '*.url', 1) If (Not IsArray($FileList)) and (@error = 1) Then
MsgBox(0, "", "No Files\Folders Found.")
Exit
EndIf

;Display $myArray's contents For$r = 1 To $FileList[0] GUICtrlCreateListViewItem($dirList[$TEST1] & " :--: " &$FileList[$r],$listview)
Next
Next
EndFunc  ;==>_LoadListView

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

# Ternary operator

##### Share on other sites

For $test3 = 1 To$fileListurl[0]
$line2 = FileReadLine(@FavoritesDir & "\" &$fileListurl[$test3], 2) GUICtrlCreateListViewItem($fileListurl[$test3] & "|" &$line2, $listview) Next Don't argue with an idiot; people watching may not be able to tell the difference. #### Share this post ##### Link to post ##### Share on other sites For$test3 = 1 To $fileListurl[0]$line2 = FileReadLine(@FavoritesDir & "\" & $fileListurl[$test3], 2)
GUICtrlCreateListViewItem($fileListurl[$test3] & "|" & $line2,$listview)
Next
Thanks again - I was kinda close, your the best. I wonder why the msgbox() could read the file name?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

# Ternary operator

##### Share on other sites

#28 ·  Posted (edited)

How about this - the first stringsplit only works with [1], but the second one works with [2] - I want the second array.

#include <GuiConstants.au3>
#include <GuiListView.au3>

#Include <File.au3>
#Include <Array.au3>

Dim $Btn_TestScroll,$Btn_Exit, $msg,$Status, $i,$line2

GUICreate("ListView Scroll", 392, 322);need to fix the size

$listview = GUICtrlCreateListView("URL List|URL", 40, 30, 310, 149);need to fix the size _GUICtrlListViewSetColumnWidth($listview, 0, $LVSCW_AUTOSIZE_USEHEADER)$Btn_TestScroll = GUICtrlCreateButton("Scroll Test", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)$Status = GUICtrlCreateLabel("Remember items are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN,$SS_CENTER))

GUISetState()

_LoadListView($listview) While 1$msg = GUIGetMsg()
Select
Case $msg =$GUI_EVENT_CLOSE Or $msg =$Btn_Exit
ExitLoop
Case $msg =$Btn_TestScroll
For $i = 10 To 50 Step 10 _GUICtrlListViewScroll($listview, 0, $i) Sleep(500) _GUICtrlListViewScroll($listview, 0, $i - ($i * 2))
Sleep(500)
Next
EndSelect
WEnd
Exit

Func _LoadListView(ByRef $listview)$dirList = _FileListToArray(@FavoritesDir, '*', 2)
If (Not IsArray($dirList)) and (@error = 1) Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf$fileListurl = _FileListToArray(@FavoritesDir, '*.url', 1)
If (Not IsArray($fileListurl)) and (@error = 1) Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf For$test3 = 1 To $fileListurl[0]$line2 = FileReadLine(@FavoritesDir & "\" & $fileListurl[$test3], 2)
$line2 = StringSplit($line2, "=")
$line2 =$line2[1]
GUICtrlCreateListViewItem($fileListurl[$test3] & "|" & $line2,$listview)
Next

For $TEST1 = 1 To$dirList[0]
GUICtrlCreateListViewItem($dirList[$TEST1], $listview)$FileList = _FileListToArray(@FavoritesDir & "\" & $dirList[$TEST1], '*.url', 1)
If (Not IsArray($FileList)) and (@error = 1) Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf ;Display$myArray's contents
For $r = 1 To$FileList[0]
$line3 = FileReadLine(@FavoritesDir & "\" &$dirList[$TEST1] & "\" &$FileList[$r], 2)$line3 = StringSplit($line3, "=")$line3 = $line3[2] GUICtrlCreateListViewItem($dirList[$TEST1] & " :--: " &$FileList[$r] & "|" &$line3, $listview) Next Next EndFunc ;==>_LoadListView edit - fixed code tags Edited by nitekram All by me: "Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace$ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection # Ternary operator #### Share this post ##### Link to post ##### Share on other sites bump All by me: "Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace$ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection # Ternary operator #### Share this post ##### Link to post ##### Share on other sites works for me here and at home. #include <GuiConstants.au3> #include <GuiListView.au3> #Include <File.au3> #Include <Array.au3> Dim$Btn_TestScroll, $Btn_Exit,$msg, $Status,$i, $line2 GUICreate("ListView Scroll", 392, 322);need to fix the size$listview = GUICtrlCreateListView("URL List|URL", 40, 30, 310, 149);need to fix the size
_GUICtrlListViewSetColumnWidth($listview, 0,$LVSCW_AUTOSIZE_USEHEADER)

$Btn_TestScroll = GUICtrlCreateButton("Scroll Test", 150, 230, 90, 40)$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("Remember items are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER)) GUISetState() _LoadListView($listview)

While 1
$msg = GUIGetMsg() Select Case$msg = $GUI_EVENT_CLOSE Or$msg = $Btn_Exit ExitLoop Case$msg = $Btn_TestScroll For$i = 10 To 50 Step 10
_GUICtrlListViewScroll($listview, 0,$i)
Sleep(500)
_GUICtrlListViewScroll($listview, 0,$i - ($i * 2)) Sleep(500) Next EndSelect WEnd Exit Func _LoadListView(ByRef$listview)
$dirList = _FileListToArray(@FavoritesDir, '*', 2) If (Not IsArray($dirList)) and (@error = 1) Then
MsgBox(0, "", "No Files\Folders Found.")
Exit
EndIf

$fileListurl = _FileListToArray(@FavoritesDir, '*.url', 1) If (Not IsArray($fileListurl)) and (@error = 1) Then
MsgBox(0, "", "No Files\Folders Found.")
Exit
EndIf

For $test3 = 1 To$fileListurl[0]
$line2 = FileReadLine(@FavoritesDir & "\" &$fileListurl[$test3], 2)$line2 = StringSplit($line2, "=")$line2 = $line2[2] GUICtrlCreateListViewItem($fileListurl[$test3] & "|" &$line2, $listview) Next For$TEST1 = 1 To $dirList[0] GUICtrlCreateListViewItem($dirList[$TEST1],$listview)
$FileList = _FileListToArray(@FavoritesDir & "\" &$dirList[$TEST1], '*.url', 1) If (Not IsArray($FileList) Or @error) Then
;~             MsgBox(0, "", "No Files\Folders Found.")
ContinueLoop
EndIf

;Display $myArray's contents For$r = 1 To $FileList[0]$line3 = FileReadLine(@FavoritesDir & "\" & $dirList[$TEST1] & "\" & $FileList[$r], 2)
$line3 = StringSplit($line3, "=")
$line3 =$line3[2]
GUICtrlCreateListViewItem($dirList[$TEST1] & " :--: " & $FileList[$r] & "|" & $line3,$listview)
Next
Next
EndFunc  ;==>_LoadListView

Don't argue with an idiot; people watching may not be able to tell the difference.

##### Share on other sites

I copied your script and got the same error message I was receiving on both home and work.

>Running: (3.1.1.111):C:\Program Files\AutoIt3\beta\autoit3.exe "Z:\scripts\URL_lister.au3"

Z:\scripts\URL_lister.au3 (55) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$line2 =$line2[2]

$line2 = ^ ERROR All by me: "Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace$ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection # Ternary operator #### Share this post ##### Link to post ##### Share on other sites try with more error checking #include <GuiConstants.au3> #include <GuiListView.au3> #Include <File.au3> #Include <Array.au3> Dim$Btn_TestScroll, $Btn_Exit,$msg, $Status,$i, $line2 GUICreate("ListView Scroll", 392, 322);need to fix the size$listview = GUICtrlCreateListView("URL List|URL", 40, 30, 310, 149);need to fix the size
_GUICtrlListViewSetColumnWidth($listview, 0,$LVSCW_AUTOSIZE_USEHEADER)

$Btn_TestScroll = GUICtrlCreateButton("Scroll Test", 150, 230, 90, 40)$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("Remember items are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER)) GUISetState() _LoadListView($listview)

While 1
$msg = GUIGetMsg() Select Case$msg = $GUI_EVENT_CLOSE Or$msg = $Btn_Exit ExitLoop Case$msg = $Btn_TestScroll For$i = 10 To 50 Step 10
_GUICtrlListViewScroll($listview, 0,$i)
Sleep(500)
_GUICtrlListViewScroll($listview, 0,$i - ($i * 2)) Sleep(500) Next EndSelect WEnd Exit Func _LoadListView(ByRef$listview)
$dirList = _FileListToArray(@FavoritesDir, '*', 2) If (Not IsArray($dirList)) and (@error = 1) Then
MsgBox(0, "", "No Files\Folders Found.")
Exit
EndIf

$fileListurl = _FileListToArray(@FavoritesDir, '*.url', 1) If (Not IsArray($fileListurl)) and (@error = 1) Then
MsgBox(0, "", "No Files\Folders Found.")
Exit
EndIf

For $test3 = 1 To$fileListurl[0]
$line2 = FileReadLine(@FavoritesDir & "\" &$fileListurl[$test3], 2)$line2 = StringSplit($line2, "=") If Not @error And$line2[0] > 1 Then
$line2 =$line2[2]
GUICtrlCreateListViewItem($fileListurl[$test3] & "|" & $line2,$listview)
EndIf
Next

For $TEST1 = 1 To$dirList[0]
GUICtrlCreateListViewItem($dirList[$TEST1], $listview)$FileList = _FileListToArray(@FavoritesDir & "\" & $dirList[$TEST1], '*.url', 1)
If (Not IsArray($FileList) Or @error) Then ;~ MsgBox(0, "", "No Files\Folders Found.") ContinueLoop EndIf ;Display$myArray's contents
For $r = 1 To$FileList[0]
$line3 = FileReadLine(@FavoritesDir & "\" &$dirList[$TEST1] & "\" &$FileList[$r], 2)$line3 = StringSplit($line3, "=") If Not @error And$line3[0] > 1 Then
$line3 =$line3[2]
GUICtrlCreateListViewItem($dirList[$TEST1] & " :--: " & $FileList[$r] & "|" & $line3,$listview)
EndIf
Next
Next
EndFunc   ;==>_LoadListView

Don't argue with an idiot; people watching may not be able to tell the difference.

##### Share on other sites

try with more error checking

That worked - can you explain it to me though. I have not done anything with error handling and have tired to read the help file and got lost. Does anyone have a detailed explanation of what it does and how it works?

I guess the reason that I am asking is I want to learn, but also @gafrost stated his worked at home and work - so how come my did not?

I have used my own error checking to make sure a variable matches the type I want coming from an end user - just not sure of @ERROR or SetError () - any help would make me post less

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

# Ternary operator

##### Share on other sites

That worked - can you explain it to me though. I have not done anything with error handling and have tired to read the help file and got lost. Does anyone have a detailed explanation of what it does and how it works?

I guess the reason that I am asking is I want to learn, but also @gafrost stated his worked at home and work - so how come my did not?

I have used my own error checking to make sure a variable matches the type I want coming from an end user - just not sure of @ERROR or SetError () - any help would make me post less

1st thing i did was to see what happens with stringsplit:

1 - delimiter found

2 - delmiter not found: @error is set and the array[0] is set to 1

So that made me think there might be a problem with a few files on your system(s).

Don't argue with an idiot; people watching may not be able to tell the difference.

##### Share on other sites

1st thing i did was to see what happens with stringsplit:

1 - delimiter found

2 - delmiter not found: @error is set and the array[0] is set to 1

So that made me think there might be a problem with a few files on your system(s).

I got you - but that also means that the files that broke it are not being displayed - right? I will have to set up a condition for those where I do not split the string and it shows - maybe in a different color font would work.

I know that this will be an on going issue as I have tried to copy files with windows before and got stuck because of a weird character in the file name (how come they just don't check at the start of the saving of the file - I will never know) - anyway if anyone is interested in the program that I found for coping any files and gives a break out of the bad ones it is YCOPY - but does anyone have something written in AutoIT for this same functionality?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection