Sign in to follow this  
Followers 0

Array file and dir list

35 posts in this topic

Posted (edited)

I am trying to break out both the dir and files from a folder. What I want is for each folder to be listed and each file under the folder to be listed as well, but with the folder heading listed as well for those files.

edit - new code - almost there

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

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

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


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

GUICreate("ListView Scroll", 392, 322)

$listview = GUICtrlCreateListView("URL", 40, 30, 310, 149)

;$FileList =12




For $TEST1 In $dirList
	GUICtrlCreateListViewItem($TEST1, $listview)
	$FileList = _FileListToArray (@FavoritesDir & "\" & $TEST1, '*.url', 1)
	If (Not IsArray($FileList)) and (@error = 1) Then
		MsgBox(0, "", "No Files\Folders Found.")
		Exit
	EndIf
	
	$rows = UBound($FileList)
	$dims = UBound($FileList, 0)
	
	For $r = 0 To UBound($FileList, 1) - 1
			For $dims in $FileList -$r
				GUICtrlCreateListViewItem($dims, $listview)
			Next
	Next
Next

$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()
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

When I do this I get each folder listed countless times. Can anyone point me in the right direction.

Thanks

EDIT =- Changed code - but same thing happens

EDIT 2 - thought I found my error - but now it says it must be declared as an object?

Edited by nitekram

Share this post


Link to post
Share on other sites



Posted

BUMP - plus I changed the code - but still same issue.

Share this post


Link to post
Share on other sites

Posted (edited)

BUMP - plus I changed the code - but still same issue.

Never mind I found it - I had declared a variable and never took it out.

Edit - I feal really stupid saying I found it - but it still is messed up - any help

Edited by nitekram

Share this post


Link to post
Share on other sites

Posted (edited)

Never mind I found it - I had declared a variable and never took it out.

Edit - I feal really stupid saying I found it - but it still is messed up - any help

OK - I have to BUMP this as I believe those that read it the last time might have thought that I was able to figure it out. I think I need to use Ubound but I am unable to figure it out.

EDIT - Added code that I am trying to figure out.

EDIT - Cleand up code with TidyIT

EDIT - DELETED CODE - ALL $#$!#$$!##$ UP - I have no clue. Can you tell?

Edited by nitekram

Share this post


Link to post
Share on other sites

Posted

OK - I have to BUMP this as I believe those that read it the last time might have thought that I was able to figure it out. I think I need to use Ubound but I am unable to figure it out.

EDIT - Added code that I am trying to figure out.

EDIT - Cleand up code with TidyIT

EDIT - DELETED CODE - ALL $#$!#$$!##$ UP - I have no clue. Can you tell?

OK - Please help

New Code - still does not do what I want

#include <GuiConstants.au3>
#include <GuiListView.au3>
#Include <File.au3>
#Include <Array.au3>

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

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


GUICreate("ListView Scroll", 392, 322)
$listview = GUICtrlCreateListView("URL",40, 30, 310, 149)

For $TEST1 IN $dirlist
GUICtrlCreateListViewItem($TEST1, $listview)

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

$rows = UBound($FileList)
$dims = UBound($FileList, 0)

;MsgBox(0, "The " & $dims & "-dimensional array has", _
;    $rows & " rows, " & $cols & " columns")

;Display $myArray's contents
$output = ""
For $r = 0 to UBound($FileList,1) - 1
    $output = $output & @LF
Next
;MsgBox(4096,"Array Contents", $output)
;MsgBox (0,"test", $output)

GUICtrlCreateListViewItem($fileList[$rows], $listview)
	
Next

$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()
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

Share this post


Link to post
Share on other sites

Posted

BUMP

since no one is reader or replying

newest code - so close

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

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

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


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

GUICreate("ListView Scroll", 392, 322)

$listview = GUICtrlCreateListView("URL",40, 30, 310, 149)

;$FileList =12




For $TEST1 IN $dirlist
GUICtrlCreateListViewItem($TEST1, $listview)


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

$rows = UBound($FileList)
$dims = UBound($FileList, 0)

;MsgBox(0, "The " & $dims & "-dimensional array has", _
;    $rows & " rows, " & $cols & " columns")

;Display $myArray's contents
For $r = 0 to UBound($FileList,1) - 1
	GUICtrlCreateListViewItem($r, $listview)
	$FileList=_FileListToArray(@FavoritesDir & "\" & $TEST1,'*.url',1)
		If (Not IsArray($FileList)) and (@Error=1) Then
			MsgBox (0,"","No Files\Folders Found.")
		Exit
		EndIf

For $rows in $fileList
	GUICtrlCreateListViewItem($rows, $listview)
	Next
Next
;MsgBox(4096,"Array Contents", $output)
;MsgBox (0,"test", $output)
	



Next

#cs
For $test2 in  $fileList
	GUICtrlCreateListViewItem($TEST1, $listview)
Next
#ce





$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()
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

Share this post


Link to post
Share on other sites

Posted

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

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

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


GUICreate("ListView Scroll", 392, 322)

$listview = GUICtrlCreateListView("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
	
	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)
			;================================================================================================
			; not sure what your trying to do here
;~ 			$FileList2 = _FileListToArray(@FavoritesDir & "\" & $dirList[$TEST1], '*.url', 1)
;~ 			If (Not IsArray($FileList)) and (@error = 1) Then
;~ 				MsgBox(0, "", "No Files\Folders Found.")
;~ 				Exit
;~ 			EndIf
;~
;~ 			For $rows = 1 To $FileList2[0]
;~ 				GUICtrlCreateListViewItem($FileList2[$rows], $listview)
;~ 			Next
			;================================================================================================
		Next
	Next
EndFunc   ;==>_LoadListView

Share this post


Link to post
Share on other sites

Posted

Bump - I added the newest code to the first post - it is really close now. If anyone wants to help - please do.

Share this post


Link to post
Share on other sites

Posted

Close?

Share this post


Link to post
Share on other sites

Posted (edited)

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

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

Dim $Btn_TestScroll, $Btn_Exit, $msg, $Status, $i
GUICreate("ListView Scroll", 392, 322)

$listview = GUICtrlCreateListView("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
	
	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)
			;================================================================================================
			; not sure what your trying to do here
;~ 			$FileList2 = _FileListToArray(@FavoritesDir & "\" & $dirList[$TEST1], '*.url', 1)
;~ 			If (Not IsArray($FileList)) and (@error = 1) Then
;~ 				MsgBox(0, "", "No Files\Folders Found.")
;~ 				Exit
;~ 			EndIf
;~
;~ 			For $rows = 1 To $FileList2[0]
;~ 				GUICtrlCreateListViewItem($FileList2[$rows], $listview)
;~ 			Next
			;================================================================================================
		Next
	Next
EndFunc   ;==>_LoadListView
I thank you and wish that I had seen your reply an hour ago - my mind hurts from changing things around - and I still never got close. I am going to study this code and see what I do not understand and hope to ask more questions. I have to go to bed :D as I am done for the night.

Again I thank you and would have never ever been able to do this without your help. I wish I just could get this.

EDIT - you never even used Ubound() - now I am completly lost.

Edited by nitekram

Share this post


Link to post
Share on other sites

Posted

Close?

Well I thought I was close - meaning that the folders were displaying and the files were displaying - just the files were displaying 3 times 3. I know have taken a look at your code and found that you are using [0] for what I was trying to use Ubound() for. Is there another example of using Ubound() as I have stated in another post - $output does not display anything (from the help file).

Here is the thread in question.

http://www.autoitscript.com/forum/index.ph...c=29062&hl=

Thanks for any help - I am still trying to understand these terms and the way they work together.

Share this post


Link to post
Share on other sites

Posted (edited)

Well I thought I was close - meaning that the folders were displaying and the files were displaying - just the files were displaying 3 times 3. I know have taken a look at your code and found that you are using [0] for what I was trying to use Ubound() for. Is there another example of using Ubound() as I have stated in another post - $output does not display anything (from the help file).

Here is the thread in question.

http://www.autoitscript.com/forum/index.ph...c=29062&hl=

Thanks for any help - I am still trying to understand these terms and the way they work together.

well being you are using _FileListToArray, the [0] = Number of Files\Folders returned

you only need to use UBound if you don't know the size of the array

quick example:

Dim $array[Random(1,100,1)]

MsgBox(0,"Ubound",UBound($array))

The example doesn't populate anything into the array, therefore the msgbox displays nothing but line feeds.

Edited by gafrost

Share this post


Link to post
Share on other sites

Posted

maybe this minor change to that example will help you better:

Dim $myArray[10][20]   ;element 0,0 to 9,19
$rows = UBound($myArray)
$cols = UBound($myArray, 2)
$dims = UBound($myArray, 0)

MsgBox(0, "The " & $dims & "-dimensional array has", _
		$rows & " rows, " & $cols & " columns")

; populate for display purposes
For $r = 0 To UBound($myArray, 1) - 1
	For $c = 0 To UBound($myArray, 2) - 1
		$myArray[$r][$c] = $c
	Next
Next

;Display $myArray's contents
$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
MsgBox(4096, "Array Contents", $output)

Share this post


Link to post
Share on other sites

Posted

maybe this minor change to that example will help you better:

Dim $myArray[10][20]   ;element 0,0 to 9,19
$rows = UBound($myArray)
$cols = UBound($myArray, 2)
$dims = UBound($myArray, 0)

MsgBox(0, "The " & $dims & "-dimensional array has", _
		$rows & " rows, " & $cols & " columns")

; populate for display purposes
For $r = 0 To UBound($myArray, 1) - 1
	For $c = 0 To UBound($myArray, 2) - 1
		$myArray[$r][$c] = $c
	Next
Next

;Display $myArray's contents
$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
MsgBox(4096, "Array Contents", $output)
I guess my confusion is that Ubound is for arrays that are unknown (as you stated) - yet in the help file example, the array is defined as $myArray[10][20]. But now that you have given an example it is a little clearer (like mud :D)

I am going to do some searches on the forum and read some more.

Thanks again

Share this post


Link to post
Share on other sites

Posted

being you do know the dimensions of the array it could of been written as such:

Dim $myArray[10][20]   ;element 0,0 to 9,19
$rows = UBound($myArray)
$cols = UBound($myArray, 2)
$dims = UBound($myArray, 0)

MsgBox(0, "The " & $dims & "-dimensional array has", _
		$rows & " rows, " & $cols & " columns")

; populate for display purposes
For $r = 0 To 9
	For $c = 0 To 19
		$myArray[$r][$c] = $c
	Next
Next

;Display $myArray's contents
$output = ""
For $r = 0 To 9
	$output = $output & @LF
	For $c = 0 To 19
		$output = $output & $myArray[$r][$c] & " "
	Next
Next
MsgBox(4096, "Array Contents", $output)

Share this post


Link to post
Share on other sites

Posted (edited)

Sorry about this - but I copied the code from the forum - removed comments for the most part and then got an error. But the same script runs fine on my home PC - any ideas?

#include <GuiConstants.au3>
#include <GuiListView.au3>
#Include <File.au3>
#Include <Array.au3>

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

GUICreate("ListView Scroll", 392, 322)

$listview = GUICtrlCreateListView("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
    
    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

The error I receive is:

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

Z:\scripts\favorites_list.au3 (56) : ==> Subscript used with non-Array variable.:

EDIT - on difference between the computers - I have a lot more favorites on my work computer than my home computer - could that be the cause?

Edited by nitekram

Share this post


Link to post
Share on other sites

Posted (edited)

had same problem at work try:

Func _LoadListView(ByRef $listview)
    $dirList = _FileListToArray(@FavoritesDir, '*', 2)
    If (Not IsArray($dirList)) Or (@error = 1) Then
        MsgBox(0, "", "No Files\Folders Found.")
        Return
    EndIf
    
    For $TEST1 = 1 To $dirList[0]
        GUICtrlCreateListViewItem($dirList[$TEST1], $listview)
        
        
        $FileList = _FileListToArray(@FavoritesDir & "\" & $dirList[$TEST1], '*.url', 1)
        If (Not IsArray($FileList)) Or (@error = 1) Then
            ContinueLoop
        EndIf
        
        ;Display $myArray's contents
        For $r = 1 To $FileList[0]
            GUICtrlCreateListViewItem($dirList[$TEST1] & " :--: " & $FileList[$r], $listview)
        Next
    Next
EndFunc
Edited by gafrost

Share this post


Link to post
Share on other sites

Posted

had same problem at work try:

Func _LoadListView(ByRef $listview)
    $dirList = _FileListToArray(@FavoritesDir, '*', 2)
    If (Not IsArray($dirList)) Or (@error = 1) Then
        MsgBox(0, "", "No Files\Folders Found.")
        Return
    EndIf
    
    For $TEST1 = 1 To $dirList[0]
        GUICtrlCreateListViewItem($dirList[$TEST1], $listview)
        
        
        $FileList = _FileListToArray(@FavoritesDir & "\" & $dirList[$TEST1], '*.url', 1)
        If (Not IsArray($FileList)) Or (@error = 1) Then
            ContinueLoop
        EndIf
        
        ;Display $myArray's contents
        For $r = 1 To $FileList[0]
            GUICtrlCreateListViewItem($dirList[$TEST1] & " :--: " & $FileList[$r], $listview)
        Next
    Next
EndFunc
That worked - can you explain why?

Share this post


Link to post
Share on other sites

Posted

looking at the function in the include error is not set but 0 is returned when no files are found.

To my thinking error should be set in this scenario also.

Share this post


Link to post
Share on other sites

Posted

looking at the function in the include error is not set but 0 is returned when no files are found.

To my thinking error should be set in this scenario also.

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?

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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?

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted

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

thanks for your help!

Share this post


Link to post
Share on other sites

Posted

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

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  
Followers 0




  • Recently Browsing   0 members

    No registered users viewing this page.