Sign in to follow this  
Followers 0
MikelSevrel

It keeps adding everytime I push the button...

2 posts in this topic

hello, I'm trying to make a program work, but everytimeI click a button to dump information into a file it builds up. The first time: Monday,Friday,Saturday, second time, Monday,Friday,SaturdayMonday,Friday,Saturday, third time, Monday,Friday,SaturdayMonday,Friday,SaturdayMonday,Friday,Saturday... I can't seem to get rid of it.

Here's the main GUI:

; == GUI generated with Koda ==
#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <Date.au3>
#include <ini.au3>


Dim $close, $folderbutton, $vdubbutton, $schedulebutton, $startime, $endtime
Dim $Date, $radio, $launchmanager, $Radio1, $Radio2, $Radio3, $POTATO

    GUICtrlDelete($days)
_start()
Func _start()
    _defaults ()
    _Inputs()
    _Buttons()
    _Labels()
    _stuff()
    _days()
    
    _DaysGoneBy()
EndFunc  ;==>_start

Func _Inputs()
    $Form1 = GUICreate("Scheduler", 348, 361)
    $title = GUICtrlCreateInput($inivar[2][1], 12, 24, 148, 21, -1, $WS_EX_CLIENTEDGE)
    $folder = GUICtrlCreateInput($inivar[4][1], 13, 64, 118, 21, -1, $WS_EX_CLIENTEDGE)
    $vdub = GUICtrlCreateInput($inivar[1][1], 13, 104, 118, 21, -1, $WS_EX_CLIENTEDGE)
    $device = GUICtrlCreateInput($inivar[5][1], 13, 144, 148, 21, -1, $WS_EX_CLIENTEDGE)
    $channel = GUICtrlCreateInput($inivar[3][1], 13, 184, 148, 21, -1, $WS_EX_CLIENTEDGE)
EndFunc  ;==>_Inputs

Func _Buttons()
    $folderbutton = GUICtrlCreateButton("...", 136, 64, 21, 21)
    $vdubbutton = GUICtrlCreateButton("...", 136, 104, 21, 21)
    $schedulebutton = GUICtrlCreateButton("Add to Schedule", 12, 328, 320, 25)
    $launchmanager = GUICtrlCreateButton("View Schedule", 12, 296, 95, 25)
    $ini = GUICtrlCreateButton("Save As Defaults", 124, 296, 95, 25)
    $close = GUICtrlCreateButton("Close", 236, 296, 95, 25)
EndFunc  ;==>_Buttons


Func _Labels()
    GUICtrlCreateLabel("Program Title", 16, 8, 66, 16)
    GUICtrlCreateLabel("VDub Location", 16, 88, 75, 16)
    GUICtrlCreateLabel("Destination Folder", 16, 48, 89, 16)
    GUICtrlCreateLabel("End Time", 16, 248, 49, 16)
    GUICtrlCreateLabel("Start Time", 16, 208, 52, 16)
    GUICtrlCreateLabel("Start Time", 16, 208, 52, 16)
    GUICtrlCreateLabel("Date", 192, 160, 27, 16)
EndFunc  ;==>_Labels

Func _stuff()
    $startime = GUICtrlCreateDate($inivar[7][1], 12, 224, 148, 21, BitOR($DTS_SHORTDATEFORMAT, $DTS_UPDOWN, $DTS_TIMEFORMAT))
    $endtime = GUICtrlCreateDate($inivar[13][1], 12, 264, 148, 21, BitOR($DTS_SHORTDATEFORMAT, $DTS_UPDOWN, $DTS_TIMEFORMAT))
    $Date = GUICtrlCreateDate(_NowDate(), 188, 184, 148, 21, BitOR($DTS_SHORTDATEFORMAT, $DTS_UPDOWN))
    $ListView = GUICtrlCreateListView("Day", 188, 24, 145, 134, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
    _GUICtrlListViewSetColumnWidth ($ListView, 0, 135)
    GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
    GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
    GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
    GUICtrlCreateListViewItem("Sunday", $ListView)
    GUICtrlCreateListViewItem("Monday", $ListView)
    GUICtrlCreateListViewItem("Tuesday", $ListView)
    GUICtrlCreateListViewItem("Wednesday", $ListView)
    GUICtrlCreateListViewItem("Thursday", $ListView)
    GUICtrlCreateListViewItem("Friday", $ListView)
    GUICtrlCreateListViewItem("Saturday", $ListView)
    GUISetState()
EndFunc  ;==>_stuff

Func _DaysGoneBy()
    $Group1 = GUICtrlCreateGroup("When to Capture?", 192, 216, 137, 73)
    $Radio1 = GUICtrlCreateRadio("Specify by Date", 200, 232, 113, 16)
    $Radio2 = GUICtrlCreateRadio("These Days Only", 200, 248, 113, 16)
    $Radio3 = GUICtrlCreateRadio("Every Selected Day", 200, 264, 113, 16)
    GUICtrlSetState($Radio3, $GUI_CHECKED)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateLabel("Device Name", 16, 128, 69, 16)
    GUICtrlCreateLabel("Days of the Week", 192, 8, 90, 16)
    GUICtrlCreateLabel("Channel", 16, 168, 43, 16)
    GUISetState(@SW_SHOW)
EndFunc  ;==>_DaysGoneBy

Func _days()
    $dates = StringSplit($inivar[8][1], ",")
    For $i = 0 To $dates[0]
        _SetDay($ListView, $dates[$i])
    Next
EndFunc  ;==>_days

Func _SetDay(ByRef $lv_days, $t_input)
    Local $found_day = 0, $x
    For $x = 0 To _GUICtrlListViewGetItemCount ($lv_days) - 1
        If StringInStr(StringUpper(_GUICtrlListViewGetItemText ($lv_days, $x, 0)), StringUpper($t_input)) Then
            GUICtrlSetState($lv_days, $GUI_FOCUS)
            _GUICtrlListViewSetCheckState ($lv_days, $x)
            $found_day = 1
            ExitLoop
        EndIf
    Next
EndFunc  ;==>_SetDay



Func _Duration()
    $startime2 = StringSplit(GUICtrlRead($startime), ":")
    $endtime2 = StringSplit(GUICtrlRead($endtime), ":")
    $startime2 = $startime2[1] * 60 + $startime2[2] + $startime2[2] / 60
    $endtime2 = $endtime2[1] * 60 + $endtime2[2] + $endtime2[2] / 60
    $duration = $endtime2 - $startime2
EndFunc  ;==>_Duration

Func _Determine()
    If $pie = 0 Then
        $vdub = GUICtrlRead($vdub)
    EndIf
EndFunc  ;==>_Determine


Func _Radio()
    If GUICtrlRead($Radio1) = $GUI_CHECKED Then
        $radio = 1
    ElseIf GUICtrlRead($Radio2) = $GUI_CHECKED Then
        $radio = 2
    ElseIf GUICtrlRead($Radio3) = $GUI_CHECKED Then
        $radio = 3
    EndIf
EndFunc  ;==>_Radio

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $folderbutton
                $path = @WorkingDir
                $folderout = FileSelectFolder("Output Directory", "")
                GUICtrlSetState($folder, $GUI_FOCUS)
                GUICtrlSetData($folder, $folderout)
                FileChangeDir($path)
                $cherry = 3
            Case $msg = $vdubbutton
                $path = @WorkingDir
                $vdub1 = FileOpenDialog("Open VDub.exe", $inivar[1][1], "Exe files (*.exe)", 0, "vdub.exe")
                GUICtrlSetState($vdub, $GUI_FOCUS)
                GUICtrlSetData($vdub, $vdub1)
                $vdub = $vdub1
                $pie = 3
                FileChangeDir($path)
            Case $msg = $schedulebutton
                
                _Determine()
                _Duration()
                _Radio()
                _Ini ()
                _Checked()          
                MsgBox(0, "Scheduled", "Your Program has been Scheduled")
                $inivar = IniReadSection($PRIORITY,"Title")
                _start()
            Case $msg = $ini
                _Determine()
                _Duration()
                _Radio()
                _Checked ()
                _IniWrite2 (@WorkingDir & "\schedule\default.ini")
                MsgBox(0, "Defaults Saved", "Defaults Have Been Saved")
                Exit
            Case $msg = $launchmanager
                RunWait(@WorkingDir & "\manager.exe")
                Exit
                
            Case $msg = $GUI_EVENT_CLOSE Or $msg = $close
                Exit
        EndSelect
    WEnd
And the "ini.au3" file that it points to:

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


Dim $time, $title, $days, $now, $vdub, $folder, $device, $duration, $ini, $Date,  $endtime
Dim $every, $command, $section, $i, $channel, $scheduled, $var, $ininames, $id, $cancel
Dim $split, $program, $ListView, $0, $1, $2, $3, $4, $5, $6, $7, $found_day, $t_input, $startime
Dim $Checked, $every, $is_Checked, $every2, $inivar, $viewitem, $file, $dates, $radio, $PRIORITY
Dim $ListViewItemWeekly, $ListViewItemNextWeek, $msg, $filename, $vdub1, $vdub2, $schedule, $pie, $cherry




Func _FileName()
For $i = 1 To 30
    If FileExists(GUICtrlRead($folder) & "\" & GUICtrlRead($title) & $i & ".avi") = 0 Then
        $filename = GUICtrlRead($folder) & "\" & GUICtrlRead($title) & $i & ".avi"
    ExitLoop
EndIf
Next
EndFunc 


Func _defaults()
        If FileExists(@WorkingDir & "\schedule\default.ini") = 1 Then
            $inivar = IniReadSection(@WorkingDir & "\schedule\default.ini", "Title")
            
        Else
            DirCreate("schedule") 
            MsgBox(0, "", "Default Configuration File Created")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "vdub", "C:\Program Files\VirtualDub\virtualdub.exe")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "title", "Capture")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "channel", "31")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "folder", "C:\My Videos")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "device", "bt878")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "duration", "60")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "startime", "8:00:00 PM")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "Dates", "Monday,Tuesday")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "Every", "3")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "FullLine", "C:\Program Files\VirtualDub\virtualdub.exe /capture /capchannel 31 /capdevice bt878 /capfile ""C:\My Videos\Capture1.avi""  /capstart 60")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "FileName", @WorkingDir & "\schedule\scheduleCapture12.ini")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "Date", "2/26/2006")
            IniWrite(@WorkingDir & "\schedule\default.ini", "Title", "Endtime", "10:00:00 PM")
            $inivar = IniReadSection(@WorkingDir & "\schedule\default.ini", "Title")
        EndIf
    Return $inivar
EndFunc  ;==>_defaults


Func _Checked()
    GUICtrlSetData($days,"")
    For $r = 0 To _GUICtrlListViewGetItemCount ($ListView)
        $Checked = _GUICtrlListViewGetCheckedState ($ListView, $r)
        If ($Checked <> $LV_ERR) Then
            If ($Checked) Then
                $days = $days & _GUICtrlListViewGetItemText ($ListView, $r) & ","
        
            EndIf
        Else
        EndIf
    Next
EndFunc  ;==>_Checked


Func _ConvertToMilTime($s_date)
    If StringUpper(StringMid($s_date, StringLen($s_date) - 1, 2)) = "PM" Then
        $s_date = StringSplit(StringTrimRight($s_date, 2), ":")
        If Number($s_date[1]) < 12 Then $s_date[1] = Number($s_date[1]) + 12
    ElseIf StringUpper(StringMid($s_date, StringLen($s_date) - 1, 2)) = "AM" Then
        $s_date = StringSplit(StringTrimRight($s_date, 2), ":")
        If Number($s_date[1]) == 12 Then $s_date[1] = "0"
    Else
        $s_date = StringSplit($s_date, ":")
        If Number($s_date[1]) == 12 Then $s_date[1] = "0"
    EndIf
    Return StringFormat("%02d:%02d", $s_date[1], $s_date[2])
EndFunc  ;==>_ConvertToMilTime



Func _FileFunctions($t)
    $i = $t
    If FileExists(@WorkingDir & "\schedule\schedule" & GUICtrlRead($title) & $i & ".ini") Then
        _FileFunctions($i + 1)
    ElseIf $t = @WorkingDir & "\schedule\default.ini" Then
        FileDelete(@WorkingDir & "\schedule\default.ini")
        _IniWrite2 (@WorkingDir & "\schedule\default.ini")
    Else
        _IniWrite2 (@WorkingDir & "\schedule\schedule" & GUICtrlRead($title) & $i & ".ini")
    EndIf
EndFunc  ;==>_FileFunctions

Func _ini()
    If $CmdLine[0] <> 0 Then
        _IniWrite2($CmdLine[1])
    Else
        $name = _FileListToArray (@WorkingDir & "\schedule", "schedule" & GUICtrlRead($title) & "*.ini")
    If IsArray($name) Then
            _FileFunctions(1)
    Else
            $i = 1
            If FileExists(@WorkingDir & "\schedule\schedule" & GUICtrlRead($title) & $i & ".ini") Then
                _FileFunctions(1)
                
            Else
                _IniWrite2(@WorkingDir & "\schedule\schedule" & GUICtrlRead($title) & $i & ".ini")
                $PRIORITY = @WorkingDir & "\schedule\schedule" & GUICtrlRead($title) & $i & ".ini"
            EndIf
        EndIf
    EndIf
EndFunc  ;==>_ini


Func _IniWrite2($path)
    _FileName()
    IniWrite($path, "Title", "vdub", $vdub)
    IniWrite($path, "Title", "title", GUICtrlRead($title))
    IniWrite($path, "Title", "channel", GUICtrlRead($channel))
    IniWrite($path, "Title", "folder", GUICtrlRead($folder))
    IniWrite($path, "Title", "device", GUICtrlRead($device))
    IniWrite($path, "Title", "duration", $duration)
    IniWrite($path, "Title", "startime", GUICtrlRead($startime))
    IniWrite($path, "Title", "Dates", $days)
    IniWrite($path, "Title", "Every", $radio)
    IniWrite($path, "Title", "FullLine", $vdub & " /capture /capchannel " & GUICtrlRead($channel) & " /capdevice " & GUICtrlRead($device) & " /capfile """ & $filename & """  /capstart " & GUICtrlRead($duration))
    IniWrite($path, "Title", "FileName", $path)
    IniWrite($path, "Title", "Date", GUICtrlRead($Date))
    IniWrite($path, "Title", "Endtime", GUICtrlRead($endtime))
    FileCopy(@WorkingDir & "\schedule\default.ini", @WorkingDir & "\tmp\", 8)
    FileMove(@WorkingDir & "\tmp\default.ini", $filename)
EndFunc
If anyone could help me resolve this, that'd be great.

Coming soon....

Share this post


Link to post
Share on other sites



should this

Func _Checked()
    GUICtrlSetData($days,"")
    For $r = 0 To _GUICtrlListViewGetItemCount ($ListView)
        $Checked = _GUICtrlListViewGetCheckedState ($ListView, $r)
        If ($Checked <> $LV_ERR) Then
            If ($Checked) Then
                $days = $days & _GUICtrlListViewGetItemText ($ListView, $r) & ","
        
            EndIf
        Else
        EndIf
    Next
EndFunc ;==>_Checked

be

Func _Checked()
    $days = ""
    For $r = 0 To _GUICtrlListViewGetItemCount ($ListView)
        $Checked = _GUICtrlListViewGetCheckedState ($ListView, $r)
        If ($Checked <> $LV_ERR) Then
            If ($Checked) Then
                $days = $days & _GUICtrlListViewGetItemText ($ListView, $r) & ","
        
            EndIf
        Else
        EndIf
    Next
EndFunc ;==>_Checked

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

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