Jump to content
Sign in to follow this  
Drew

Help - Function of mine.

Recommended Posts

Drew

Alright , I'm having a bit of trouble with this function , getting it to work properly.

What it needs to do:

Check the data folder in the scripts directory for any .ini files.

If their found:

Write their information accordingly to the ListView on the main GUI.

Script Function:

Func _UpDateListView()
    $FileSearch = FileExists( @ScriptDir& "\Data\")
            If $FileSearch = 1 Then
    $ListView1 = GUICtrlCreateListView("Name | Genre | Subtitles | Year | Length", 8, 64, 337, 353)
            $ini1 = IniRead(@ScriptDir&"\Data\"&".ini", "Details", "Genre", "Not Found")
            $ini2 = IniRead(@ScriptDir&"\Data\"&".ini", "Details", "Subtitles", "Not Found")
            $ini3 = IniRead(@ScriptDir&"\Data\"&".ini", "Details", "Year", "Not Found")
            $ini4 = IniRead(@ScriptDir&"\Data\"&".ini", "Details", "Length", "Not Found")
        GUICtrlCreateListViewItem( $ini1 &"|"& $ini2 &"|"& $ini3 &"|"& $ini4 , $ListView1)
    EndIf
EndFunc

Any help is appreciated.

Share this post


Link to post
Share on other sites
martin

Alright , I'm having a bit of trouble with this function , getting it to work properly.

What it needs to do:

Check the data folder in the scripts directory for any .ini files.

If their found:

Write their information accordingly to the ListView on the main GUI.

Script Function:

Func _UpDateListView()
    $FileSearch = FileExists( @ScriptDir& "\Data\")
            If $FileSearch = 1 Then
    $ListView1 = GUICtrlCreateListView("Name | Genre | Subtitles | Year | Length", 8, 64, 337, 353)
            $ini1 = IniRead(@ScriptDir&"\Data\"&".ini", "Details", "Genre", "Not Found")
            $ini2 = IniRead(@ScriptDir&"\Data\"&".ini", "Details", "Subtitles", "Not Found")
            $ini3 = IniRead(@ScriptDir&"\Data\"&".ini", "Details", "Year", "Not Found")
            $ini4 = IniRead(@ScriptDir&"\Data\"&".ini", "Details", "Length", "Not Found")
        GUICtrlCreateListViewItem( $ini1 &"|"& $ini2 &"|"& $ini3 &"|"& $ini4 , $ListView1)
    EndIf
EndFunc

Any help is appreciated.

Look up FileFindFirstFile and FileFindNextFile.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Drew

AFter me trying to implement this:

Func _UpDateListView()

$IniSearch = FileFindFirstFile(@ScriptDir & "\Data\*.ini")

If $IniSearch = -1 Then

MsgBox(0, "No Titles Match", "Report this error to Dreu.")

Exit

EndIf

While 1

$file = FileFindNextFile($IniSearch)

If @error Then ExitLoop

$ListView1 = GUICtrlCreateListView("Name | Genre | Subtitles | Year | Length", 8, 64, 337, 353)

$ini1 = IniRead(@ScriptDir &"\"&$File, "Details", "Genre", "Not Found")

$ini2 = IniRead(@ScriptDir &"\"&$File, "Details", "Subtitles", "Not Found")

$ini3 = IniRead(@ScriptDir &"\"&$File, "Details", "Year", "Not Found")

$ini4 = IniRead(@ScriptDir &"\"&$File, "Details", "Length", "Not Found")

GUICtrlCreateListViewItem($ini1 & "|" & $ini2 & "|" & $ini3 & "|" & $ini4, $ListView1)

WEnd

EndFunc

K. I tried putting the function in the main while loop ( bad idea... contantly does it... logically of course. )

And I tried putting it up top of the script , thinking it would run the function soon as the script starts. <-- Didn't work. Didn't even show the "Not Found" return error on the IniRead's like it did when I put it in the While loop.

I'm sure somethings wrong in how I layed out for it to create the ListViewItem , but I can't find where.

Share this post


Link to post
Share on other sites
Drew

Update:

Newly scripted test function:

Purpose: Same purpose. Just using message box to display the key for testing purposes to ensure it's working properly.

Code:

Func _UpDateListView()
    $IniSearch = FileFindFirstFile(@ScriptDir & "\Data\*.ini")
    If $IniSearch = -1 Then
        MsgBox(0, "No Titles Match", "Report this error to Dreu.")
        Exit
    EndIf
    While 1
        $file = FileFindNextFile($IniSearch)
        If @error Then ExitLoop
        $ya = IniRead( $file, "Details", "Genre", "Genre Wasn't Found")
        MsgBox( 0, "Found.", "This: "&$ya)
    WEnd
Edited by Drew

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.