Jump to content

Recommended Posts

Posted (edited)

Good day,

I have been updating a previous script that was|is based on [Playlist Maker] by ragnarok775 - along with With updates as provided by Andreik! [Thank you!]

I am trying to understand this script and have one question: "How to I "trigger" the "Else" located at line 54 [...from line 55 to  line 68]?"
• The initial If|Then|Else I have been able to derive output [Line 47 to 54], however.

Here is the section:

Spoiler
#include <ExtMsgBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Global $hGUI, $_ListView, $_sCol1Row1, $_sCol1Row2

$hGUI = GUICreate(" GUI", 940, 375)
GUISetFont(12, 0, 0, "Segoe UI Semibold")

; COLUMN 1 BUTTONS
Global $_sCol1Row2 = GUICtrlCreateButton("Add to List", 10, 40, 200, 25)

; ListView
Global $_ListView = GUICtrlCreateListView("ListView", 220, 10, 500, 355)
_GUICtrlListView_SetColumnWidth($_ListView, 0, 490)

GUISetState(@SW_SHOW, $hGUI)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
            ; ---------------------
            ; COLUMN 1 BUTTONS
        Case $_sCol1Row2
            AddToList($_ListView)
    EndSwitch
WEnd

Func AddToList($_ListView)
    Local $sResult, $WorkingDir, $iItem, $sFileSelectDialog, $aSplit, $sMsg1
    Local $MyBox = MsgBox(4, "Does a Show file exist?", "Yes or No")
    ; -------------------------
    If $MyBox == 7 Then
        CreateShowFile($_ListView)
    ElseIf $MyBox == 6 Then
        ; -----------------
        $WorkingDir = "F:\Audio"
        $sFileSelectDialog = FileOpenDialog("Select Session Files", $WorkingDir, "Data Files (*.edl; *.shw)", 4)
        ; -------------------------
        If @error Then Return SetError(1, 0, Null)
        ; -------------------------
        $aSplit = StringSplit($sFileSelectDialog, "|")
        ; -------------------------
        If Not IsArray($aSplit) Then Return SetError(1, 0, Null)
        ; -----------------
        If $aSplit[0] = 1 Then
            $iItem = _GUICtrlListView_FindText($_ListView, $aSplit[1], -1, False)
            ; -----------------
            If $iItem = -1 Then
                GUICtrlCreateListViewItem($aSplit[1], $_ListView)
            Else
                MsgBox(0x40, "Info!!", $aSplit[1] & " is already in the Session Listing1.")
            EndIf
        Else    
            ; << BEGIN HERE!! >>
            _GUICtrlListView_BeginUpdate($_ListView)
            ; -----------------
            For $Index = 2 To $aSplit[0]
                $iItem = _GUICtrlListView_FindText($_ListView, $aSplit[1] & "\" & $aSplit[$Index], -1, False)
                ; -----------------
                If $iItem = -1 Then
                    GUICtrlCreateListViewItem($aSplit[1] & "\" & $aSplit[$Index], $_ListView)
                    ConsoleWrite($aSplit[1] & "\" & $aSplit[$Index] & @CRLF)
                Else
                    MsgBox(0x40, "Info!", $aSplit[1] & "\" & $aSplit[$Index] & " is already in the Session Listing2.")
                EndIf
            Next
            ; << END HERE!! >>
            ; -----------------
            _GUICtrlListView_EndUpdate($_ListView)
        EndIf
    EndIf
EndFunc   ;==>AddToList

Func CreateShowFile($_ListView)
    Local $hFile, $iCount
    Local $DstSaveDir = "F:\Audio"
    Local $sSave = FileSaveDialog("Enter Show Filename", $DstSaveDir, "Show File (*.shw)", 18)
    ; -------------------------
    If @error Then Return SetError(1, 0, Null)
    ; ---------------------
    If StringRight($sSave, 4) <> ".shw" Then $sSave &= ".shw"
    ; -------------------------
    $hFile = FileOpen($sSave, 2) ; FO_OVERWRITE
    $iCount = _GUICtrlListView_GetItemCount($_ListView)
    ; -------------------------
    For $Index = 0 To $iCount - 1
        FileWriteLine($hFile, _GUICtrlListView_GetItemText($_ListView, $Index))
    Next
    ; -------------------------
    FileClose($hFile)
EndFunc   ;==>CreateShowFile

As always...any assistance in this matter would be greatly appreciated!

PS: If I had to provide a concerted effort at guessing what the above does, the section does "nothing", and therefore, I am becoming convinced that this above section is not required?

Edited by mr-es335

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
×
×
  • Create New...