MuffettsMan

does _GUICtrlComboBox_SetCurSel need some sort of gui refresh? >_<

8 posts in this topic

I have been using _GUICtrlComboBox_SetCurSel all over my script to force a combo box to be one of two elements depending on the situation... works everwhere but when i come to this bit of script...

$query = "SELECT * FROM NOTIFICATION WHERE default_check = "  & $default_check & " AND backup_queue_id = " & $backup_queue_id & " AND TYPE = " & $type & ";"
   $row = SQLiteResult($query)

   ; _ArrayDisplay($row)
   ; $var - table row - $gui element name
   ; $row[1][2] - name - $Name
   ; $row[1][3] - email - $EmailAddress
   ; $row[1][4] - type - $Type = _GUICtrlComboBox_SetCurSel ( $Type, 0) ; set default choice 0 Success or 1 Error... lol backwards
   ; $row[1][5] - log_check - $LogCheck = 1 is checked 4 is unchecked....
   ; $row[1][6] - subject - $EmailSubject
   ; $row[1][7] - body - $EmailBody

   ; FINALLY UPDATE TEH #@!!@$@ GUI.....
   GUICtrlSetData($Name, $row[1][2])
   GUICtrlSetData($EmailAddress, $row[1][3])



   if $row[1][4] = 1 Then ; 1 is a success... which is the first element in the dropdown
      ConsoleWrite("Success TYPE: " & $row[1][4] & @CRLF)
      _GUICtrlComboBox_SetCurSel ( $Type, 0)
   Else ; is a fail... which is the second element in the dropdown
      ConsoleWrite("Fail TYPE: " & $row[1][4] & @CRLF)
     _GUICtrlComboBox_SetCurSel ( $Type, 1)
   EndIf

   GUICtrlSetData($LogCheck, $row[1][5])
   GUICtrlSetData($EmailSubject, $row[1][6])
   GUICtrlSetData($EmailBody, $row[1][7])

EVERYTHING else on the tab updates just fine the console writes confirm one or the other elements are being run... hell i can change them both to _GUICtrlComboBox_SetCurSel ( $Type, -1) which should simply clear the combo box and it won't do it... tried adding a sleep(1000) to see if some other rogue code was changing the combo back immediately after but it just won't change >_<

any ideas?


Don't let that status fool you, I am no advanced memeber!

Share this post


Link to post
Share on other sites



Can you show us the creation of the ComboBox and any other pertinent information that deals with this Control?


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

the whole code though might be too much of a headache to read through....

hmm looks like you need to manually create a 'data' folder in the same directory... should have done that by default but atm thats the least of my worries.....

so when u first launch it, it creates the tables, detects there isn't any default settings for each category (you can just click "Update Default Settings" on each of the tabs to proceed... when it gets to the Notifications tab you can see it will actually change the combo box.....  however once u get past loading the default settings and jump back to the notifications tab, select something in the details list and hit load (had major issues trying to get it to load on click like i can with the main backup list on the first tab which is why there is a load button >_< but thats anotther story) anyway so it loads the name email address subject etc etc but won't change the #@! type dropdown >_<

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GUIToolTip.au3>
#include <GUIListView.au3>
#include <GuiScrollBars.au3>

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>

#include <GuiEdit.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>

#include <SQLite.au3>
#include <SQLite.dll.au3>

#include <File.au3>




; *************************************************************
; Global Variables
; *************************************************************
Global $backupList ; full array of to-do list
Global $logFile = FileOpen(@ScriptDir & "\data\ccd.log", 1)

; *************************************************************
; Adding SQLite db to store user settings
; *************************************************************
; moved away from ini files (for saving user data)
; as ini files work well for saving GUI settings
; start to have formatting issues when saving large
; volumes of text - Furthermore, it is simply a text
; file containing login information that could be
; easily read or altered accidentally
; SQLite is the workaround - it's small lightweight
; and its db flatfile isn't just plain text
; *************************************************************

; *************************************************************
; Initial SQLite settup
; *************************************************************
; will create a new DB in scripts directory if one
; doesn't already exist - will build default tables
; If db already exists queries will be ignored
; Next, a check to ensure default settings exists,
; if none are found a prompt to save will execute.
; *************************************************************


Local $hQuery, $aRow

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)

Local $sDbName = @ScriptDir & "\data\BackupApp.db"
ConsoleWrite("sDbName: " & $sDbName & @CRLF)

Local $hDskDb = _SQLite_Open($sDbName) ; Open a permanent disk database
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't open or create a permanent Database!")
    Exit -1
 EndIf

; *************************************************************
; backup_queue Table: Creation
; *************************************************************
; This table holds the files and folders that are to be
; processed.
;
; The default_action, default_schedule, and default_notification
; track if the defaults should be used = 1 or custom = 0
; if any = 0 then they will have a record in the corresponding
; action, schedule, or notification tables.
; *************************************************************
_SQLite_Exec(-1, "Create table IF NOT EXISTS backup_queue (" & _
            "id INTEGER PRIMARY KEY AUTOINCREMENT, " & _
            "name TEXT NOT NULL, " & _
            "path TEXT NOT NULL, " & _
            "location TEXT NOT NULL UNIQUE, " & _
            "folder INTEGER NOT NULL, " & _
            "default_action INTEGER NOT NULL, " & _
            "default_schedule INTEGER NOT NULL, " & _
            "default_notification INTEGER NOT NULL);")

; *************************************************************
; action Table: Creation
; *************************************************************
; This table holds the local file copy, ftp copy, compression
; settings, and count of redudant files to keep on the server
; basically all data that pertains to actions that need to be
; executed on the backup queue list.
;
; When app starts will check for a row with default_check = 1
; (if none exists will prompt to create) only one default
; should exists all other rows will be default_check = 0 and
; have backup_queue_id = ## for file that isn't using the
; default values.
; *************************************************************

; _SQLite_Exec(-1, "DROP TABLE action;")

_SQLite_Exec(-1, "Create table IF NOT EXISTS action (" & _
            "default_check INTEGER NOT NULL UNIQUE, " & _
            "backup_queue_id INTEGER NOT NULL, " & _
            "redudntant_count INTEGER, " & _
            "copy_check INTEGER, " & _
            "copy_destination TEXT, " & _
            "ftp_check INTEGER, " & _
            "ftp_host TEXT, " & _
            "ftp_user TEXT, " & _
            "ftp_password TEXT, " & _
            "ftp_directory TEXT, " & _
            "rar_check INTEGER, " & _
            "rar_password TEXT, " & _
            "rar_compression INTEGER, " & _
            "zip_check INTEGER, " & _
            "sfx_check INTEGER, " & _
            "sfx_icon_check INTEGER, " & _
            "sfx_logo_check INTEGER, " & _
            "split_check INTEGER, " & _
            "split_size INTEGER);")


; *************************************************************
; schedule Table: Creation
; *************************************************************
; This table holds the schedule settings for when the action
; table should execute. execution_time is the time of day to
; start, frequency is a count in hours of how often to execute
; ie 0 for once or 8 for 3 times a day, 12 for twice.
;
; When app starts will check for a row with default_check = 1
; (if none exists will prompt to create) only one default
; should exists all other rows will be default_check = 0 and
; have backup_queue_id = ## for file that isn't using the
; default values.
; *************************************************************

; _SQLite_Exec(-1, "DROP TABLE schedule;")

_SQLite_Exec(-1, "Create table IF NOT EXISTS schedule (" & _
            "default_check INTEGER NOT NULL UNIQUE, " & _
            "backup_queue_id INTEGER NOT NULL, " & _
            "execution_time TEXT," & _
            "frequency INTEGER, " & _
            "mon_check INTEGER, " & _
            "tue_check INTEGER, " & _
            "wed_check INTEGER, " & _
            "thu_check INTEGER, " & _
            "fri_check INTEGER, " & _
            "sat_check INTEGER, " & _
            "sun_check INTEGER);")

; *************************************************************
; notification Table: Creation
; *************************************************************
; This table holds the notification settings for who / what
; notifications should be sent on a success (type = 1) or
; failure (type = 0).  log_check option will include the current
; log file attached to the email.
;
; When app starts will check for a row with default_check = 1
; (if none exists will prompt to create) only one default
; should exists all other rows will be default_check = 0 and
; have backup_queue_id = ## for file that isn't using the
; default values.
; *************************************************************

; _SQLite_Exec(-1, "DROP table notification;")

$query = "Create table IF NOT EXISTS notification (" & _
            "default_check INTEGER, " & _
            "backup_queue_id INTEGER NOT NULL, " & _
            "name TEXT, " & _
            "email_address TEXT, " & _
            "type INTEGER, " & _
            "log_check INTEGER, " & _
            "email_subject TEXT, " & _
            "email_body TEXT, UNIQUE (default_check, type));" ;

ConsoleWrite("Query: " & $query & @CRLF)
_SQLite_Exec(-1, $query)

; *************************************************************
; Initial GUI Creation
; *************************************************************
; Visual Editor - Koda FormDesigner
; template - Form1.kxf (backup in the data directory)
; *************************************************************
Opt("GUIDataSeparatorChar", "|") ;"|" is the default

$Form1 = GUICreate("Form1", 484, 499, 252, 146)
$TabSheet = GUICtrlCreateTab(12, 16, 457, 469)
$TabSheet1 = GUICtrlCreateTabItem("To-Do List")
GUICtrlSetState(-1,$GUI_SHOW)
$Group3 = GUICtrlCreateGroup("Backup Queue", 16, 49, 449, 313)
$addFiles = GUICtrlCreateButton("Add Files", 224, 325, 73, 25)
$fileList = GUICtrlCreateListView("", 24, 73, 433, 243, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_SUBITEMIMAGES,$LVS_EX_FULLROWSELECT))
   ; Add columns
    _GUICtrlListView_InsertColumn($fileList, 0, "ID", 25)
    _GUICtrlListView_InsertColumn($fileList, 1, "File Name", 150)
    _GUICtrlListView_InsertColumn($fileList, 2, "Path", 240)



GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
$removeFiles = GUICtrlCreateButton("Remove", 384, 325, 73, 25)
$addFolder = GUICtrlCreateButton("Add Folder", 304, 325, 73, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\data\logo.jpg", 16, 372, 448, 100)
$TabSheet2 = GUICtrlCreateTabItem("Actions")
$Group4 = GUICtrlCreateGroup("Data Archive Manager", 16, 49, 449, 413)
$defaultAction = GUICtrlCreateButton("Update Default Settings", 160, 69, 129, 25)
$saveAction = GUICtrlCreateButton("Save Settings", 384, 425, 73, 25)
$Checkbox1 = GUICtrlCreateCheckbox("Use Default Settings", 28, 73, 121, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$ArchivedCount = GUICtrlCreateInput("5", 28, 97, 25, 21, $ES_NUMBER) ; only enter numbers
$ArchivedCountLabel = GUICtrlCreateLabel("Archived Redundant Copy Count", 60, 101, 160, 17)
$Group1 = GUICtrlCreateGroup("Local Copy", 24, 120, 269, 137)
$WindowsCopyCheck = GUICtrlCreateCheckbox("Windows File Copy to a Local / Network Path", 36, 144, 241, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$ActionSource = GUICtrlCreateInput("<default>", 100, 172, 185, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))

GUICtrlSetBkColor($ActionSource,0xD9D9D9)
$WindowsDestinationFolder = GUICtrlCreateInput("", 100, 200, 109, 21)
$Label1 = GUICtrlCreateLabel("Source:", 36, 176, 41, 17)
$Label2 = GUICtrlCreateLabel("Destination:", 36, 204, 60, 17)
$ActionWinFolder = GUICtrlCreateButton("Select Folder", 212, 196, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("FTP Copy", 24, 260, 269, 161)
$FtpCheck = GUICtrlCreateCheckbox("Send File to a FTP Server", 36, 284, 181, 17)
$Label4 = GUICtrlCreateLabel("Host Name:", 36, 312, 60, 17)
$FtpHost = GUICtrlCreateInput("", 128, 308, 121, 21)
$Label5 = GUICtrlCreateLabel("User Name:", 36, 340, 60, 17)
$FtpUser = GUICtrlCreateInput("", 128, 336, 121, 21)
$Label6 = GUICtrlCreateLabel("Password:", 36, 368, 53, 17)
$FtpPassword = GUICtrlCreateInput("", 128, 364, 121, 21)
$Label7 = GUICtrlCreateLabel("Remote Directory:", 36, 396, 89, 17)
$FtpDir = GUICtrlCreateInput("", 128, 392, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group8 = GUICtrlCreateGroup("Compression Settings", 296, 120, 161, 301)
$RarCheck = GUICtrlCreateCheckbox("Create RAR Archive", 308, 144, 117, 17)
$RarPassword = GUICtrlCreateInput("", 372, 168, 77, 21)
$Label13 = GUICtrlCreateLabel("Password:", 300, 172, 53, 17)
$RarCompressionCombo = GUICtrlCreateCombo("", 372, 200, 77, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "0 - Store|1 - Least|2 - Slight|3 - Default|4 - High|5 - Highest")
_GUICtrlComboBox_SetCurSel ( $RarCompressionCombo, 3) ; set default compression as default choice
$Label14 = GUICtrlCreateLabel("Compression:", 300, 204, 67, 17)
$Group9 = GUICtrlCreateGroup("Compression Type", 300, 228, 153, 105)
$RarZipCheck = GUICtrlCreateCheckbox("Use Zip Format", 308, 244, 97, 17)
$RarSfxCheck = GUICtrlCreateCheckbox("Self Extracting Archive", 308, 264, 141, 17)
$RarSfxIcon = GUICtrlCreateCheckbox("Include CCD Icon", 308, 284, 129, 17)
$RarSfxLogo = GUICtrlCreateCheckbox("Include CCD Logo", 308, 304, 109, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group10 = GUICtrlCreateGroup("Split Volumes", 300, 340, 153, 77)
$RarVolumeCheck = GUICtrlCreateCheckbox("Create Volumes", 308, 360, 97, 17)
$Label15 = GUICtrlCreateLabel("Size:", 308, 388, 27, 17)
$RarVolumeSize = GUICtrlCreateInput("0", 340, 384, 57, 21, $ES_NUMBER) ; only enter numbers
$Label16 = GUICtrlCreateLabel("MB", 400, 388, 20, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$BackupImmediately = GUICtrlCreateButton("Backup Immediatly", 24, 425, 107, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$TabSheet3 = GUICtrlCreateTabItem("Scheduling")
$Group5 = GUICtrlCreateGroup("Execution Times", 16, 49, 449, 413)
$defaultSchedule = GUICtrlCreateButton("Update Default Settings", 160, 69, 129, 25)
$saveSchedule = GUICtrlCreateButton("Save Settings", 384, 425, 73, 25)
$Checkbox5 = GUICtrlCreateCheckbox("Use Default Settings", 28, 73, 121, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Group6 = GUICtrlCreateGroup("Rules", 24, 108, 433, 309)
$ScheduleSource = GUICtrlCreateInput("", 124, 128, 265, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetBkColor($ScheduleSource,0xD9D9D9)
$Label8 = GUICtrlCreateLabel("Source:", 36, 132, 41, 17)
$Label9 = GUICtrlCreateLabel("Execution Time:", 36, 160, 80, 17)
$ExecutionTime = GUICtrlCreateDate("", 124, 156, 86, 21, $DTS_TIMEFORMAT)
$Label10 = GUICtrlCreateLabel("Frequency: ", 36, 188, 60, 17)
$Frequency = GUICtrlCreateInput("0", 124, 184, 61, 21, $ES_NUMBER)
$Label11 = GUICtrlCreateLabel("Hours (Leave blank or 0 to only run once)", 192, 188, 200, 17)
$Label12 = GUICtrlCreateLabel("(Time of day to start)", 220, 160, 100, 17)
$Group7 = GUICtrlCreateGroup("Days", 36, 224, 93, 169)
$MonCheck = GUICtrlCreateCheckbox("Monday", 44, 244, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$TueCheck = GUICtrlCreateCheckbox("Tuesday", 44, 264, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$WedCheck = GUICtrlCreateCheckbox("Wednesday", 44, 284, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$ThuCheck = GUICtrlCreateCheckbox("Thursday", 44, 304, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$FriCheck = GUICtrlCreateCheckbox("Friday", 44, 324, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$SatCheck = GUICtrlCreateCheckbox("Saturday", 44, 344, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$SunCheck = GUICtrlCreateCheckbox("Sunday", 44, 364, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$TabSheet4 = GUICtrlCreateTabItem("Notifications")
$Group11 = GUICtrlCreateGroup("Contact Information", 16, 49, 449, 413)
$defaultNotification = GUICtrlCreateButton("Update Default Settings", 160, 69, 129, 25)
$saveNotification = GUICtrlCreateButton("Save Settings", 384, 425, 73, 25)
$loadDetails = GUICtrlCreateButton("Load Details", 24, 425, 107, 25)
$Checkbox25 = GUICtrlCreateCheckbox("Use Default Settings", 28, 73, 121, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Group12 = GUICtrlCreateGroup("Details", 24, 108, 433, 309)
$NotifListView = GUICtrlCreateListView("", 36, 128, 409, 67, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_SUBITEMIMAGES,$LVS_EX_FULLROWSELECT))
   ; Add columns
    _GUICtrlListView_InsertColumn($NotifListView, 0, "Default", 25)
    _GUICtrlListView_InsertColumn($NotifListView, 1, "ID", 25)
    _GUICtrlListView_InsertColumn($NotifListView, 2, "Type", 40)
    _GUICtrlListView_InsertColumn($NotifListView, 3, "Address", 100)
    _GUICtrlListView_InsertColumn($NotifListView, 4, "Subject", 190)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
$Name = GUICtrlCreateInput("", 72, 200, 121, 21)
$Label17 = GUICtrlCreateLabel("Name:", 36, 204, 35, 17)
$Label18 = GUICtrlCreateLabel("Email Address:", 196, 204, 73, 17)
$EmailAddress = GUICtrlCreateInput("", 268, 200, 177, 21)
$Type = GUICtrlCreateCombo("", 128, 228, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "1 - Success|0 - Error")
_GUICtrlComboBox_SetCurSel ( $Type, 0) ; set default choice

$Label19 = GUICtrlCreateLabel("Notification Type:", 36, 232, 87, 17)
$Label20 = GUICtrlCreateLabel("Email Subject / Body:", 36, 260, 106, 17)
$EmailSubject = GUICtrlCreateInput("", 140, 256, 305, 21)
$LogCheck = GUICtrlCreateCheckbox("Include Debug Log", 284, 232, 113, 17)
$EmailBody = GUICtrlCreateEdit("", 36, 284, 409, 125)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet5 = GUICtrlCreateTabItem("Event Log")
; Adding LOG
; $LogGroup = GUICtrlCreateGroup("Log", 16, 49, 449, 413)

Global $ConsoleLog = GUICtrlCreateEdit("", 20, 48, 437, 425)


ConsoleWriteGUI("Script Starting...." & @CRLF)

Func ConsoleWriteGUI($log) ;Sends event log to SciTE console and to application log tab
     ConsoleWrite($log)
     _FileWriteLog($logFile, $log)
     ; _GUICtrlEdit_AppendText($conLog,$log & @CRLF)
     GUICtrlSetData($ConsoleLog, $log, "append")
EndFunc

; Monitor ListView for clicks...  (to update source fields of other tabs)
Func _GetChecked()
   ConsoleWrite("test" & @CRLF)
    If GUICtrlRead(@GUI_CtrlId, 1) Then ConsoleWrite(GUICtrlRead(@GUI_CtrlId) & " selected...." & @LF)
EndFunc



GUICtrlCreateTabItem("")

; handle for tooltips
$h_addFiles = GUICtrlGetHandle($addFiles)
$h_addFolder = GUICtrlGetHandle($addFolder)
$h_fileList = GUICtrlGetHandle($fileList)
$h_removeFiles = GUICtrlGetHandle($removeFiles)

; create a tooltip control using default settings
$hToolTip = _GUIToolTip_Create(0)
_GUIToolTip_SetMaxTipWidth($hToolTip, 500)

; add a tool to the tooltip control
_GUIToolTip_AddTool($hToolTip, 0, "Click here to add files to be backed up.", $h_addFiles)
_GUIToolTip_AddTool($hToolTip, 0, "Click here to REMOVE the selected file from the backup list.", $h_removeFiles)
_GUIToolTip_AddTool($hToolTip, 0, "This is the List of files & folders scheduled for backup. Select one to see details.", $h_fileList)

_GUIScrollBars_Init($fileList)
_GUIScrollBars_EnableScrollBar($fileList, $SB_HORZ, $ESB_ENABLE_BOTH)


GUISetState(@SW_SHOW)


; *************************************************************
; Database Checks
; *************************************************************
; 1st Check to see if we have default settings for each type
; *************************************************************



; *************************************************************
; Func CheckDefaults($table)
; *************************************************************
; Used during startup to verify a default option exists for the
; action, schedule, and notification table.
; *************************************************************

CheckDefaults('action', 1)
CheckDefaults('schedule', 1)
CheckDefaults('notification', 2)

Func CheckDefaults($table, $defaultCount)
   $query = "select count(*) from " & $table & " where default_check = 1";
   $count = SQLiteCheck($query);

   if $count < $defaultCount Then
      ; Call SetDefault Func to go to appropriate tab and save
      If $table == 'notification' Then
         MsgBox($MB_SYSTEMMODAL, "Information", "No Default Settings found for the " & $table & " table. NOTE: THIS TABLE REQUIRES TWO DEFAULTS!!! (One for each Type - Success and Error Notifications) Please choose options and click 'Update Default Settings'.")
      Else
         MsgBox($MB_SYSTEMMODAL, "Information", "No Default Settings found for the " & $table & " table. Please choose options and click 'Update Default Settings'.")
      EndIf


      ; Disable other tabs depending on which we are working on.....
      ; then load active tab to the corresponding type
      ; this array $afTabSheets keeps track of which tab one is allowed
      ; on 'True' depending on the case
      Switch $table
         Case "action"
            Global $afTabSheets[5] = [False, True, False, False, False]
            _GUICtrlTab_SetCurFocus($TabSheet, 1)
         Case "schedule"
            Global $afTabSheets[5] = [False, False, True, False, False]
            _GUICtrlTab_SetCurFocus($TabSheet, 2)
         Case "notification"
            Global $afTabSheets[5] = [False, False, False, True, False]
            _GUICtrlTab_SetCurFocus($TabSheet, 3)
      EndSwitch

      ; Disable the Backup Immediately button as we can't do that till
      ; all default settings are saved.
      GUICtrlSetState($BackupImmediately, $GUI_DISABLE)
      GUICtrlSetState($saveAction, $GUI_DISABLE)
      GUICtrlSetState($saveSchedule, $GUI_DISABLE)
      GUICtrlSetState($saveNotification, $GUI_DISABLE)


      While $count < $defaultCount
         Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
               ExitLoop
            Case $defaultAction
              DefaultAction()
              $query = "select count(*) from action where default_check = 1";
              $count = SQLiteCheck($query); See if we have an entry now
              ConsoleWrite("$count: " & $count & @CRLF)

            Case $defaultSchedule
              DefaultSchedule()
              $query = "select count(*) from schedule where default_check = 1";
              $count = SQLiteCheck($query); See if we have an entry now
              ConsoleWrite("$count: " & $count & @CRLF)

            Case $defaultNotification
               DefaultNotification()
              $query = "select count(*) from notification where default_check = 1";
              $count = SQLiteCheck($query); See if we have an entry now
              ConsoleWrite("$count: " & $count & " of " & $defaultCount & @CRLF)

               if $count = 1 Then
                  MsgBox($MB_SYSTEMMODAL, "Information", "Last one... set a default error message and click 'Update Default Settings'.")
                  ; assume we now need to set the default error message....
                  _GUICtrlComboBox_SetCurSel ( $Type, 1) ; set default choice
               EndIf


            Case $ActionWinFolder
               ActionWinFolder()

            Case $TabSheet
               If $afTabSheets[GUICtrlRead($TabSheet)] = False Then
                  _Lock_Tab()
               EndIf
         EndSwitch
         sleep(10)
      WEnd

   EndIf
EndFunc

; *************************************************************
; Func _Lock_Tab()
; *************************************************************
; Used during Default Setups to keep user on current tab
; till default settings are saved (see CheckDefaults func)
; *************************************************************

Func _Lock_Tab()
    For $i = 0 To 5
        If $afTabSheets[$i] = True Then
           _GUICtrlTab_SetCurFocus($TabSheet, $i)
           MsgBox($MB_SYSTEMMODAL, "Notice", "You must create default options and click 'Update Default Settings'.")
            Return
        EndIf
    Next
 EndFunc

Func IsChecked($controlID)
   If IsChecked($CheckBox) Then
      return 1
   Else
      return 0
   EndIf

EndFunc

Func ActionWinFolder()
   ; Display an open dialog to select a file.
    Local Const $sMessage = "Select a folder"
    Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
    Else
      ; update form...
      GUICtrlSetData($WindowsDestinationFolder, $sFileSelectFolder, $sFileSelectFolder)

    EndIf
EndFunc ;==> AddFolders


; NEEDS TO PAUSE HERE TILL ACTION IS SAVED....
; schedule


; notification




; #Load Data# ***********************************************************
; UpdateBackupList() loads the Queue / To-Do List on the main page
; Now we need to check for defaults
; ***********************************************************************
UpdateBackupList()
UpdateNotificationList()

_GUICtrlTab_SetCurFocus($TabSheet, 0)

; Register on click events so we can monitor
; listview clicks and update GUI according to
; id / name selected.....
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $addFiles
           AddFiles()

        Case $addFolder
           AddFolder()

        Case $removeFiles
           RemoveFiles()

        Case $loadDetails
           LoadNotificationDetails()

        Case $fileList
           ; some LoadSelected() function.....
           ; ConsoleWriteGUI("List Clicked..." & @CRLF)
           ; $menuState = GUICtrlRead($fileList) ; return the selected the menu item
           ; ConsoleWriteGUI("echo " & @ScriptLineNumber & ": Selected: " & $menuState & @CRLF)

        EndSwitch



   sleep(10) ; take it easy on the CPU.
WEnd



; Handle WM_NOTIFY messages
; used to get listview clicks on the fly
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $sClickType
    $hListView = $fileList
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $sClickType = "Left Click"
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $sClickType = "Left Double-Click"
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $sClickType = "Right Click"
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $sClickType = "Right Double-Click"
                Case Else ; We aren't interested in other messages
                    Return $GUI_RUNDEFMSG
            EndSwitch
            $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
            ConsoleWrite("WM_NOTIFY: " & $sClickType & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                    "-->Code:" & @TAB & $iCode & @LF & _
                    "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
                    "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF)

            ; Get ListView item by index.... [1] ID... [2] File Name... [3] Path...
            Global $selectedItem = _GUICtrlListView_GetItemTextArray($fileList, DllStructGetData($tInfo, "Index"))

            GUICtrlSetData($ActionSource, $selectedItem[1] & " - " & $selectedItem[2])
            GUICtrlSetData($ScheduleSource, $selectedItem[1] & " - " & $selectedItem[2])


    EndSwitch
    Return $GUI_RUNDEFMSG
 EndFunc   ;==>WM_NOTIFY



Func DefaultAction()
   ; read all tab items and insert to db....

   $ArchivedCountState = GUICtrlRead($ArchivedCount);
   $WindowsCopyCheckState = GUICtrlRead($WindowsCopyCheck);
   $WindowsDestinationFolderState = GUICtrlRead($WindowsDestinationFolder);

   $FtpCheckState = GUICtrlRead($FtpCheck);
   $FtpHostState = GUICtrlRead($FtpHost);
   $FtpUserState = GUICtrlRead($FtpUser);
   $FtpPasswordState = GUICtrlRead($FtpPassword);
   $FtpDirState = GUICtrlRead($FtpDir);

   $RarCheckState = GUICtrlRead($RarCheck);
   $RarPasswordState = GUICtrlRead($RarPassword);
   $RarCompressionComboState = StringSplit(GUICtrlRead($RarCompressionCombo), " ");
   $RarZipCheckState = GUICtrlRead($RarZipCheck);
   $RarSfxCheckState = GUICtrlRead($RarSfxCheck);
   $RarSfxIconState = GUICtrlRead($RarSfxIcon);
   $RarSfxLogoState = GUICtrlRead($RarSfxLogo);
   $RarVolumeCheckState = GUICtrlRead($RarVolumeCheck);
   $RarVolumeSizeState = GUICtrlRead($RarVolumeSize);

   ConsoleWrite("$ArchivedCountState : " & $ArchivedCountState & @CRLF)
   ConsoleWrite("$WindowsCopyCheckState : " & $WindowsCopyCheckState & @CRLF)
   ConsoleWrite("$WindowsDestinationFolderState : " & $WindowsDestinationFolderState & @CRLF)

   ConsoleWrite("$FtpCheckState : " & $FtpCheckState & @CRLF)
   ConsoleWrite("$FtpHostState : " & $FtpHostState & @CRLF)
   ConsoleWrite("$FtpUserState : " & $FtpUserState & @CRLF)
   ConsoleWrite("$FtpPasswordState : " & $FtpPasswordState & @CRLF)
   ConsoleWrite("$FtpDirState : " & $FtpDirState & @CRLF)

   ConsoleWrite("$RarCheckState : " & $RarCheckState & @CRLF)
   ConsoleWrite("$RarPasswordState : " & $RarPasswordState & @CRLF)
   ConsoleWrite("$RarCompressionComboState : " & $RarCompressionComboState[1] & @CRLF)
   ConsoleWrite("$RarZipCheckState : " & $RarZipCheckState & @CRLF)
   ConsoleWrite("$RarSfxCheckState : " & $RarSfxCheckState & @CRLF)
   ConsoleWrite("$RarSfxIconState : " & $RarSfxIconState & @CRLF)
   ConsoleWrite("$RarSfxLogoState : " & $RarSfxLogoState & @CRLF)
   ConsoleWrite("$RarVolumeCheckState : " & $RarVolumeCheckState & @CRLF)
   ConsoleWrite("$RarVolumeSizeState : " & $RarVolumeSizeState & @CRLF)

            $query = "INSERT INTO ACTION (" & _
            "default_check, " & _
            "backup_queue_id, " & _
            "redudntant_count, " & _
            "copy_check, " & _
            "copy_destination, " & _
            "ftp_check, " & _
            "ftp_host, " & _
            "ftp_user, " & _
            "ftp_password, " & _
            "ftp_directory, " & _
            "rar_check, " & _
            "rar_password, " & _
            "rar_compression, " & _
            "zip_check, " & _
            "sfx_check, " & _
            "sfx_icon_check, " & _
            "sfx_logo_check, " & _
            "split_check, " & _
            "split_size) VALUES (" & _
            "1, " & _
            "0, " & _
            $ArchivedCountState & ", " & _
            $WindowsCopyCheckState & ", " & _
            "'" & $WindowsDestinationFolderState & "', " & _
            $FtpCheckState & ", " & _
            "'" & $FtpHostState & "', " & _
            "'" & $FtpUserState & "', " & _
            "'" & $FtpPasswordState & "', " & _
            "'" & $FtpDirState & "', " & _
            $RarCheckState & ", " & _
            "'" & $RarPasswordState & "', " & _
            $RarCompressionComboState[1] & ", " & _ ; STRING SPLIT
            $RarZipCheckState & ", " & _
            $RarSfxCheckState & ", " & _
            $RarSfxIconState & ", " & _
            $RarSfxLogoState & ", " & _
            $RarVolumeCheckState & ", " & _
            $RarVolumeSizeState & ");"

            SQLiteSql($query)

EndFunc

Func DefaultSchedule()
   ; read all tab items and insert to db....
   $ExecutionTimeState = GUICtrlRead($ExecutionTime);
   $FrequencyState = GUICtrlRead($Frequency);
   $MonCheckState = GUICtrlRead($MonCheck);
   $TueCheckState = GUICtrlRead($TueCheck);
   $WedCheckState = GUICtrlRead($WedCheck);
   $ThuCheckState = GUICtrlRead($ThuCheck);
   $FriCheckState = GUICtrlRead($FriCheck);
   $SatCheckState = GUICtrlRead($SatCheck);
   $SunCheckState = GUICtrlRead($SunCheck);

   ConsoleWrite("$ExecutionTimeState : " & $ExecutionTimeState & @CRLF)
   ConsoleWrite("$FrequencyState : " & $FrequencyState & @CRLF)
   ConsoleWrite("$MonCheckState : " & $MonCheckState & @CRLF)
   ConsoleWrite("$TueCheckState : " & $TueCheckState & @CRLF)
   ConsoleWrite("$WedCheckState : " & $WedCheckState & @CRLF)
   ConsoleWrite("$ThuCheckState : " & $ThuCheckState & @CRLF)
   ConsoleWrite("$FriCheckState : " & $FriCheckState & @CRLF)
   ConsoleWrite("$SatCheckState : " & $SatCheckState & @CRLF)
   ConsoleWrite("$SunCheckState : " & $SunCheckState & @CRLF)

            $query = "INSERT INTO SCHEDULE (" & _
            "default_check, " & _
            "backup_queue_id, " & _
            "execution_time, " & _
            "frequency, " & _
            "mon_check, " & _
            "tue_check, " & _
            "wed_check, " & _
            "thu_check, " & _
            "fri_check, " & _
            "sat_check, " & _
            "sun_check) VALUES (" & _
            "1, " & _
            "0, " & _
            "'" & $ExecutionTimeState & "', " & _
            $FrequencyState & ", " & _
            $MonCheckState & ", " & _
            $TueCheckState & ", " & _
            $WedCheckState & ", " & _
            $ThuCheckState & ", " & _
            $FriCheckState & ", " & _
            $SatCheckState & ", " & _
            $SunCheckState & ");"

            SQLiteSql($query)
EndFunc

Func DefaultNotification()
   ; read all tab items and insert to db....
   $NameState = GUICtrlRead($Name);
   $EmailAddressState = GUICtrlRead($EmailAddress);
   $TypeState = StringSplit(GUICtrlRead($Type), " ");
   $LogCheckState = GUICtrlRead($LogCheck);
   $EmailSubjectState = GUICtrlRead($EmailSubject);
   $EmailBodyState = GUICtrlRead($EmailBody);

   ConsoleWrite("$NameState : " & $NameState & @CRLF)
   ConsoleWrite("$EmailAddressState : " & $EmailAddressState & @CRLF)
   ConsoleWrite("$TypeState : " & $TypeState[1] & @CRLF)
   ConsoleWrite("$LogCheckState : " & $LogCheckState & @CRLF)
   ConsoleWrite("$EmailSubjectState : " & $EmailSubjectState & @CRLF)
   ConsoleWrite("$EmailBodyState : " & $EmailBodyState & @CRLF)

            $query = "INSERT INTO notification (" & _
            "default_check, " & _
            "backup_queue_id, " & _
            "name, " & _
            "email_address, " & _
            "type, " & _
            "log_check, " & _
            "email_subject, " & _
            "email_body) VALUES (" & _
            "1, " & _
            "0, " & _
            "'" & $NameState & "', " & _
            "'" & $EmailAddressState & "', " & _
            $TypeState[1] & ", " & _
            $LogCheckState & ", " & _
            "'" & $EmailSubjectState & "', " & _
            "'" & $EmailBodyState & "');"
            SQLiteSql($query)
EndFunc

Func UpdateBackupList()
   ; remove existing items and rebuild from db table
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($fileList))

   Global $fSortSense = False ; Set initial ascending sort

   ConsoleWriteGUI("UpdateBackupList STARTED: " & @CRLF)

   ; Query
   Local $aResult, $iRows, $iColumns, $iRval
   $iRval = _SQLite_GetTable2d(-1, "SELECT * FROM backup_queue order by ID;", $aResult, $iRows, $iColumns)
   If $iRval = $SQLITE_OK Then

      ; update master backupList array:
      $backupList = $aResult

      ; for some reason _GUICtrlListView_AddSubItem bombs when trying to skip
      ; the first row (which is the column names) so going to delete it from
      ; the array instead as a workaround.....
      For $i = 0 to UBound($backupList)
          If $i== 0 Then
            _ArrayDelete($backupList, $i)
          EndIf
      Next

      ; Loop multi dim array....
      Local $iRows = UBound($backupList, 1) ; total number of rows....
      For $i = 0 To $iRows - 1
         ConsoleWriteGUI($i & ": File ID: " & $backupList[$i][0] & " File Name: " & $backupList[$i][1] & " File Path: " & $backupList[$i][2] & @CRLF)
         ; GUICtrlSetData($fileList, $backupList[$i][0] & ": " & $backupList[$i][1])
         ; Add items
         _GUICtrlListView_AddItem($fileList, $backupList[$i][0], $i)
         _GUICtrlListView_AddSubItem($fileList, $i, $backupList[$i][1], 1, 1)
         _GUICtrlListView_AddSubItem($fileList, $i, $backupList[$i][2], 2, 2)

      Next

   EndIf

   ConsoleWriteGUI("UpdateBackupList Completed." & @CRLF)
EndFunc ;==> UpdateBackupList

Func UpdateNotificationList()
   ; remove existing items and rebuild from db table
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($NotifListView))

   Global $fSortSense = False ; Set initial ascending sort

   ConsoleWriteGUI("UpdateNotificationList STARTED: " & @CRLF)

   ; Query
   Local $aResult, $iRows, $iColumns, $iRval
   $iRval = _SQLite_GetTable2d(-1, "SELECT * FROM notification order by default_check, backup_queue_id, type;", $aResult, $iRows, $iColumns)
   If $iRval = $SQLITE_OK Then

      ; update master backupList array:
      $backupList = $aResult

      ; for some reason _GUICtrlListView_AddSubItem bombs when trying to skip
      ; the first row (which is the column names) so going to delete it from
      ; the array instead as a workaround.....
      For $i = 0 to UBound($backupList)
          If $i== 0 Then
            _ArrayDelete($backupList, $i)
          EndIf
      Next

      ; Loop multi dim array....
      Local $iRows = UBound($backupList, 1) ; total number of rows....
      For $i = 0 To $iRows - 1
         ConsoleWriteGUI($i & ": default_check: " & $backupList[$i][0] & " backup_queue_id: " & $backupList[$i][1] & " Email Address: " & $backupList[$i][4] & @CRLF)
         ;  "default_check INTEGER, " & _
         ;  "backup_queue_id INTEGER NOT NULL, " & _
         ;  "name TEXT, " & _
         ;  "email_address TEXT, " & _
         ;  "type INTEGER, " & _
         ; GUICtrlSetData($fileList, $backupList[$i][0] & ": " & $backupList[$i][1])
         ; Add items
         _GUICtrlListView_AddItem($NotifListView, $backupList[$i][0], $i)
         _GUICtrlListView_AddSubItem($NotifListView, $i, $backupList[$i][1], 1, 1)
         _GUICtrlListView_AddSubItem($NotifListView, $i, $backupList[$i][4], 2, 2)
         _GUICtrlListView_AddSubItem($NotifListView, $i, $backupList[$i][3], 3, 3)
         _GUICtrlListView_AddSubItem($NotifListView, $i, $backupList[$i][6], 4, 4)

      Next

   EndIf

   ConsoleWriteGUI("UpdateBackupList Completed." & @CRLF)
EndFunc ;==> UpdateNotificationList

Func LoadNotificationDetails()
   ; ConsoleWriteGUI("UpdateNotificationTab Default Check: " & $default_check & ", BackupID: " & $backup_queue_id & ", Type: " & $type & @CRLF)

   $selectedRow = _GUICtrlListView_GetSelectedIndices($NotifListView) ; return the selected row
   ConsoleWriteGUI("$selectedRow ID: " & $selectedRow & @CRLF)

   $default_check = _GUICtrlListView_GetItemText($NotifListView, Number($selectedRow), 0)
   $backup_queue_id = _GUICtrlListView_GetItemText($NotifListView, Number($selectedRow), 1)
   $type = _GUICtrlListView_GetItemText($NotifListView, Number($selectedRow), 2)
   ConsoleWriteGUI("Default_check: " & $default_check & " $backup_queue_id: " & $backup_queue_id & " $type " & $type & @CRLF)



   $query = "SELECT * FROM NOTIFICATION WHERE default_check = "  & $default_check & " AND backup_queue_id = " & $backup_queue_id & " AND TYPE = " & $type & ";"
   $row = SQLiteResult($query)

   ; _ArrayDisplay($row)
   ; $var - table row - $gui element name
   ; $row[1][2] - name - $Name
   ; $row[1][3] - email - $EmailAddress
   ; $row[1][4] - type - $Type = _GUICtrlComboBox_SetCurSel ( $Type, 0) ; set default choice 0 Success or 1 Error... lol backwards
   ; $row[1][5] - log_check - $LogCheck = 1 is checked 4 is unchecked....
   ; $row[1][6] - subject - $EmailSubject
   ; $row[1][7] - body - $EmailBody

   ; FINALLY UPDATE TEH #@!!@$@ GUI.....
   GUICtrlSetData($Name, $row[1][2])
   GUICtrlSetData($EmailAddress, $row[1][3])



   if $row[1][4] = 1 Then ; 1 is a success... which is the first element in the dropdown
      ConsoleWrite("Success TYPE: " & $row[1][4] & @CRLF)
      _GUICtrlComboBox_SetCurSel ( $Type, 0)
   Else ; is a fail... which is the second element in the dropdown
      ConsoleWrite("Fail TYPE: " & $row[1][4] & @CRLF)
     _GUICtrlComboBox_SetCurSel ( $Type, 1)
   EndIf

   GUICtrlSetData($LogCheck, $row[1][5])
   GUICtrlSetData($EmailSubject, $row[1][6])
   GUICtrlSetData($EmailBody, $row[1][7])
  

   ; _GUICtrlComboBox_SetCurSel ( $Type, -1)


   ConsoleWriteGUI("LoadNotificationDetails Completed." & @CRLF)
EndFunc



Func AddFiles()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files."

    ; Display an open dialog to select a list of file(s).
    Local $sFileOpenDialog = FileOpenDialog($sMessage, @ScriptDir & "\", "All Files (*.*)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        ; $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)

        ; Display the list of selected files.
        ; MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog)

         $files = StringSplit($sFileOpenDialog, "|") ; only when more than one file selected....

         ; _ArrayDisplay($files)

         If $files[0] > 1 Then ; multiple files were selected (holding down ctrl)
            For $i = 2 To $files[0] ; Loop through the array returned by StringSplit to display the individual values.
               ; $i = 0 is the array size
               ; $i = 1 is the path.... need to save that to ini....
              ConsoleWriteGUI("echo " & @ScriptLineNumber & ": " & $files[$i] & @CRLF)
              ; GUICtrlSetData($fileList, $files[$i], $files[$i])

            ; HARD CODING VALUES ATM WILL NEED TO FIX IN THE END......
            ; "default_action INTEGER NOT NULL, " & _
            ; "default_schedule INTEGER NOT NULL, " & _
            ; "default_notification INTEGER NOT NULL);")

              ; Call SQLite Func to insert....
               $query = "Insert into backup_queue (name, path, location, folder, default_action, default_schedule, default_notification) values ('" & $files[$i] & "','" & $files[1] & "','" & $files[1] & "\" &  $files[$i] & "', 0, 1, 1, 1);"
               SQLiteSql($query)

               ; db updated now update gui...
               UpdateBackupList()
            Next
         Else
            $fileArray = StringSplit($sFileOpenDialog,"\")
            $file = $fileArray[$fileArray[0]] ; last element in array is file... $fileArray[0] is the count of array to get last element...
            $path = StringTrimRight($sFileOpenDialog,StringLen($fileArray[ubound($fileArray)-1]))

            ; _ArrayDisplay($OnlyFileName)
            ConsoleWriteGUI("echo " & @ScriptLineNumber & ": Path: " & $path & @CRLF)
            ConsoleWriteGUI("echo " & @ScriptLineNumber & ": File: " & $file & @CRLF)
            ; GUICtrlSetData($fileList, $file, $file)

            ; Call SQLite Func to insert....
            $query = "Insert into backup_queue (name, path, location, folder, default_action, default_schedule, default_notification) values ('" & $file & "','" & $path & "','" & $path &  $file & "', 0, 1, 1, 1);"
            SQLiteSql($query)

            ; db updated now update gui...
            UpdateBackupList()

         EndIf


    EndIf
EndFunc   ;==>Example


; SQLiteSql just runs a SQL Query....
Func SQLiteSql($query)
   Local $aResult, $iRows, $iColumns, $iRval
   ConsoleWriteGUI("QUERY: " & $query & @CRLF)
   $iRval = _SQLite_Exec(-1, $query)
   If $iRval = $SQLITE_OK Then
      ConsoleWriteGUI("Query Successful" & @CRLF)
   Else
       MsgBox(16, "SQLite Error: " & $iRval, _SQLite_ErrMsg ())
   EndIf
EndFunc ;==>SQLiteSql

; SQLiteCheck returns a count of the SQL Query....
Func SQLiteCheck($query)
   ConsoleWriteGUI("SQLiteCheck STARTED: " & @CRLF)
   Local $aResult, $iRows, $iColumns, $iRval
   $iRval = _SQLite_GetTable2d(-1, $query, $aResult, $iRows, $iColumns)
   If $iRval = $SQLITE_OK Then

      ; Loop multi dim array....
      Local $iRows = UBound($aResult, 1) ; total number of rows....
      For $i = 1 To $iRows - 1
         ConsoleWriteGUI($i & ": Count: " & $aResult[$i][0]& @CRLF)
         Return $aResult[$i][0]
      Next
   EndIf
   ConsoleWriteGUI("SQLiteCheck Completed: " & @CRLF)
EndFunc ;==> SQLiteCheck

; SQLiteResult returns a result from the SQL Query....
Func SQLiteResult($query)
   ConsoleWriteGUI("SQLiteCheck STARTED: " & @CRLF)
   Local $aResult, $iRows, $iColumns, $iRval
   $iRval = _SQLite_GetTable2d(-1, $query, $aResult, $iRows, $iColumns)
   If $iRval = $SQLITE_OK Then
         Return $aResult
   EndIf
   ConsoleWriteGUI("SQLiteCheck Completed: " & @CRLF)
EndFunc ;==> SQLiteCheck




Func AddFolder()
   ; Display an open dialog to select a file.
    Local Const $sMessage = "Select a folder"
    Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
    Else
        ; Call SQLite Func to insert....
         $query = "Insert into backup_queue (name, path, location, folder, default_action, default_schedule, default_notification) values ('" & $sFileSelectFolder & "','" & $sFileSelectFolder & "','" & $sFileSelectFolder & "', 1, 1, 1, 1);"
         SQLiteSql($query)
         ; db updated now update gui...
         UpdateBackupList()
    EndIf
EndFunc ;==> AddFolders

Func RemoveFiles()

; MsgBox($MB_SYSTEMMODAL, "Information", "Selected Indices: " & _GUICtrlListView_GetSelectedIndices($filelist))

   $selectedRow = _GUICtrlListView_GetSelectedIndices($filelist) ; return the selected row
   ConsoleWriteGUI("$selectedRow ID: " & $selectedRow & @CRLF)

   $rowID = _GUICtrlListView_GetItemText($filelist, Number($selectedRow), 0)
   $rowName = _GUICtrlListView_GetItemText($filelist, Number($selectedRow), 1)
   ConsoleWriteGUI("ID: " & $rowID & " Name: " & $rowName & @CRLF)

   $confirm = MsgBox(4096+4, "Delete Conformation", "Are you sure you want to remove " & $rowName & " from the backup list?")

   ConsoleWriteGUI(" Delete Conformation: " & $confirm & @CRLF)

   If $confirm == 6 Then
      ; 6 is the return flag for the Yes button...
      ; Call SQLite Func to insert....
      $query = "DELETE FROM backup_queue WHERE ID = " & $rowID & ";"
      SQLiteSql($query)

      ; db updated now update gui...
      UpdateBackupList()

      MsgBox(0, "DELETE", $rowName & " has been removed from the backup list.")
   EndIf

EndFunc ;==> RemoveFiles




FileClose($logFile) ; Close the filehandle to release the file.

Don't let that status fool you, I am no advanced memeber!

Share this post


Link to post
Share on other sites

I'm guessing i have some bigger issue because when i have WM_NOTIFY triggering on my To-Do list view on the first tab it works fine (click on add files and select a few) then click on one and it immediately populates the read only inputs on the actions and schedule tab to let you know which you are working on....    however when i tried to add the notifications list view to WM_NOTIFY i was able to query the db to return the full data but when i would try to display the array it would lockup autoit without any error >_< so i scrapped that idea and made the friggin button which now doesn't lock up / crash but can't update the combo box either


Don't let that status fool you, I am no advanced memeber!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

not sure if it helps... but its odd in that function - if i call _GUICtrlComboBox_SetCurSel ( $Type, -1) at the very beginning it works however if i call it after the sql query it bombs??

(see the comments inline)

Func LoadNotificationDetails()
   ; UPDATES WHEN HERE!!!!
  ; _GUICtrlComboBox_SetCurSel ( $Type, -1) 
   ; ConsoleWriteGUI("UpdateNotificationTab Default Check: " & $default_check & ", BackupID: " & $backup_queue_id & ", Type: " & $type & @CRLF)

   $selectedRow = _GUICtrlListView_GetSelectedIndices($NotifListView) ; return the selected row
   ConsoleWriteGUI("$selectedRow ID: " & $selectedRow & @CRLF)

   $default_check = _GUICtrlListView_GetItemText($NotifListView, Number($selectedRow), 0)
   $backup_queue_id = _GUICtrlListView_GetItemText($NotifListView, Number($selectedRow), 1)
   $type = _GUICtrlListView_GetItemText($NotifListView, Number($selectedRow), 2)
   ConsoleWriteGUI("Default_check: " & $default_check & " $backup_queue_id: " & $backup_queue_id & " $type " & $type & @CRLF)



   $query = "SELECT * FROM NOTIFICATION WHERE default_check = "  & $default_check & " AND backup_queue_id = " & $backup_queue_id & " AND TYPE = " & $type & ";"
   $row = SQLiteResult($query)

   ; _ArrayDisplay($row)
   ; $var - table row - $gui element name
   ; $row[1][2] - name - $Name
   ; $row[1][3] - email - $EmailAddress
   ; $row[1][4] - type - $Type = _GUICtrlComboBox_SetCurSel ( $Type, 0) ; set default choice 0 Success or 1 Error... lol backwards
   ; $row[1][5] - log_check - $LogCheck = 1 is checked 4 is unchecked....
   ; $row[1][6] - subject - $EmailSubject
   ; $row[1][7] - body - $EmailBody

   ; FAILS WHEN HERE????!!!!!
   _GUICtrlComboBox_SetCurSel ( $Type, -1)

   ; FINALLY UPDATE TEH #@!!@$@ GUI.....
   GUICtrlSetData($Name, $row[1][2])
   GUICtrlSetData($EmailAddress, $row[1][3])



   if $row[1][4] = 1 Then ; 1 is a success... which is the first element in the dropdown
      ConsoleWrite("Success TYPE: " & $row[1][4] & @CRLF)
      _GUICtrlComboBox_SetCurSel ( $Type, 0)
   Else ; is a fail... which is the second element in the dropdown
      ConsoleWrite("Fail TYPE: " & $row[1][4] & @CRLF)
     _GUICtrlComboBox_SetCurSel ( $Type, 1)
   EndIf

   GUICtrlSetData($LogCheck, $row[1][5])
   GUICtrlSetData($EmailSubject, $row[1][6])
   GUICtrlSetData($EmailBody, $row[1][7])



   ConsoleWriteGUI("LoadNotificationDetails Completed." & @CRLF)
EndFunc

Edit: so works at 907 when uncommented but not at line 933...... fml

Edited by MuffettsMan

Don't let that status fool you, I am no advanced memeber!

Share this post


Link to post
Share on other sites

Not sure what $Type is used for originally, but you reuse the variable in line 915 to hold the text of the ListView item. Variable names in AutoIt are not case sensitive, so $Type = $type = $TyPe. Whatever $Type might have signified in line 907, it no longer means anything by 915.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Not sure what $Type is used for originally, but you reuse the variable in line 915 to hold the text of the ListView item. Variable names in AutoIt are not case sensitive, so $Type = $type = $TyPe. Whatever $Type might have signified in line 907, it no longer means anything by 915.

FML seriously?! >_< uugh thats a pita cause i have done that all over the place /sigh time to change a lot of variables least ctrl H is case sensitive lol


Don't let that status fool you, I am no advanced memeber!

Share this post


Link to post
Share on other sites

thanks BrewMan...  it took a while but that fixed it!


Don't let that status fool you, I am no advanced memeber!

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