Sign in to follow this  
Followers 0
BoonPek

Masking and Unmaking $ES_PASSWORD with GuiSetStyle

7 posts in this topic

#1 ·  Posted (edited)

How can I alter the code below so that when the Show Characters checkbox is checked, then the $ES_PASSWORD style will be normal?

#include <EditConstants.au3>
#include <GuiConstantsEx.au3>

GUICreate("Test GUI", 200, 50)

$InputBox = GUICtrlCreateInput("", 5, 5, 190, 20, $ES_PASSWORD)

$CheckBox = GUICtrlCreateCheckbox("Show Characters", 5, 30)

GUISetState()

Do
    $msg = GUIGetMsg()
    Switch $msg
        Case $CheckBox
            If GUICtrlRead($CheckBox) = $GUI_CHECKED Then
                GUICtrlSetStyle($InputBox, Default)
            Else
                GUICtrlSetStyle($InputBox, $ES_PASSWORD)
            EndIf
    EndSwitch
Until $msg = $GUI_EVENT_CLOSE

Thank you.

Edited by BoonPek

Share this post


Link to post
Share on other sites



BoonPek,

Some styles cannot be changed dynamically, as the Help file tells us, and $ES_PASSWORD is one of these. :)

Take a look at this post to see a possible workaround. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thank you very much M23! ;)

I have another AutoIt related thing to ask. Is it possible to share variables between two AutoIt Files by using #include? I keep on getting warnings like "possibly used before declaration" and "undeclared global variable" even though I have already declared them.

MainGUI.au3:-

#include-once

#include <GuiConstantsEx.au3>
#include <ConfigGUI.au3>

;Credits:
;
;SmOke_N for reading the text in the list view and exporting it into an INI
;Melba23 for the checkbox mask and unmask the $ES_PASSWORD

Global $ConfigStoreStaffName, $ConfigStoreStaffPass, $ConfigStoreName, $ConfigStorePass
Global $ItemSectionRead, $StoreStaffSectionRead, $StoreNameRead, $StorePassRead
Global $Database = "Database.ini"

If Not FileExists($Database) Then
    FirstRun()
Else
    RetrieveData()
    ConfigData(1)
EndIf

Func FirstRun()
    $CreateData = MsgBox(36, "Program Name", "This seems to be your first time running this program." & @CRLF & "Do you want to create and configure your Database?")
    If $CreateData = 6 Then
        ConfigData()
    ElseIf $CreateData = 7 Then
        Exit
    EndIf
EndFunc   ;==>FIRSTRUN

Func RetrieveData()
    $ItemSectionRead = IniReadSection($Database, "Items")
    $StoreStaffSectionRead = IniReadSection($Database, "Staff")
    $StoreNameRead = IniRead($Database, "General", "Name", "")
    $StorePassRead = IniRead($Database, "General", "Name", "")
EndFunc

ConfigGUI.au3:

#include-once

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>
#include <MainGUI.au3>

Global $ConfigStoreStaffName, $ConfigStoreStaffPass, $ConfigStoreName, $ConfigStorePass
Global $ItemSectionRead, $StoreStaffSectionRead, $StoreNameRead, $StorePassRead

Func ConfigData($Data = 0)

    $ConfigGUI = GUICreate("Database Configuration", 660, 530)

    GUICtrlCreateGroup("", 5, 0, 650, 480)

    $ConfigItemList = GUICtrlCreateListView("Barcode |Item Name |Price", 15, 15, 305, 360, $LVS_REPORT)
    _GUICtrlListView_SetColumnWidth($ConfigItemList, 0, 70)
    _GUICtrlListView_SetColumnWidth($ConfigItemList, 1, 160)
    _GUICtrlListView_SetColumnWidth($ConfigItemList, 2, 70)

    GUICtrlCreateLabel("Item Name:", 15, 385, 60, 20)
    GUICtrlCreateLabel("Barcode:", 15, 415, 60, 20)
    GUICtrlCreateLabel("Price:", 170, 415, 60, 20)

    $ConfigItemName = GUICtrlCreateInput("", 80, 385, 240, 20)

    $ConfigItemCode = GUICtrlCreateInput("", 80, 415, 80, 20, $ES_NUMBER)

    $ConfigItemDollar = GUICtrlCreateInput("", 240, 415, 45, 20, $ES_NUMBER)
    GUICtrlCreateLabel(".", 287, 415, 20, 12)
    $ConfigItemCents = GUICtrlCreateInput("", 295, 415, 25, 20, $ES_NUMBER)

    GUICtrlSetLimit($ConfigItemCode, 8, 8)
    GUICtrlSetLimit($ConfigItemName, 20, 0)
    GUICtrlSetLimit($ConfigItemDollar, 4, 0)
    GUICtrlSetLimit($ConfigItemCents, 2, 0)

    $ConfigItemAdd = GUICtrlCreateButton("Add", 30, 445, 80, 25)
    $ConfigItemRem = GUICtrlCreateButton("Remove", 125, 445, 80, 25)
    $ConfigItemClr = GUICtrlCreateButton("Clear", 220, 445, 80, 25)

    GUICtrlCreateLabel("", 330, 6, 1, 473, 0x08001000)

    GUICtrlCreateLabel("Company Name:", 340, 20, 80, 20)
    GUICtrlCreateLabel("Admin Pass:", 340, 50, 80, 20)
    GUICtrlCreateLabel("Staff Name:", 340, 385, 80, 20)
    GUICtrlCreateLabel("Staff Pass:", 340, 415, 80, 20)

    $ConfigStoreStaffList = GUICtrlCreateListView("Staff Name |Staff Password", 340, 90, 305, 285, $LVS_REPORT)
    _GUICtrlListView_SetColumnWidth($ConfigStoreStaffList, 0, 160)
    _GUICtrlListView_SetColumnWidth($ConfigStoreStaffList, 1, 140)

    $ConfigStoreName = GUICtrlCreateInput("", 425, 20, 220, 20)
    $ConfigStorePass = GUICtrlCreateInput("", 425, 50, 220, 20, $ES_PASSWORD)

    GUICtrlCreateLabel("", 329, 80, 327, 1, 0x08001000)

    $ConfigStoreStaffName = GUICtrlCreateInput("", 425, 385, 220, 20)
    $ConfigStoreStaffPass = GUICtrlCreateInput("", 425, 415, 220, 20, $ES_PASSWORD)

    GUICtrlSetLimit($ConfigStoreName, 20, 0)
    GUICtrlSetLimit($ConfigStorePass, 20, 0)
    GUICtrlSetLimit($ConfigStoreStaffName, 20, 0)
    GUICtrlSetLimit($ConfigStoreStaffPass, 20, 0)

    $ConfigStoreStaffAdd = GUICtrlCreateButton("Add", 355, 445, 80, 25)
    $ConfigStoreStaffRem = GUICtrlCreateButton("Remove", 450, 445, 80, 25)
    $ConfigStoreStaffClr = GUICtrlCreateButton("Clear", 545, 445, 80, 25)

    $ConfigSaveButton = GUICtrlCreateButton("Save", 190, 495, 80, 25)
    $ConfigClrButton = GUICtrlCreateButton("Clear All", 290, 495, 80, 25)
    $ConfigCancelButton = GUICtrlCreateButton("Cancel", 390, 495, 80, 25)

    If $Data = 1 Then
        For $i = 1 to $ItemSectionRead[0][0]
            $ConfigItemReadCode = $ItemSectionRead[$i][0]
            $ConfigItemNamePrice = StringSplit($ItemSectionRead[$i][1], "|")
            $ConfigItemReadName = $ConfigItemNamePrice[1]
            $ConfigItemReadPrice = $ConfigItemNamePrice[2]
            GUICtrlCreateListViewItem($ConfigItemReadCode & "|" &  $ConfigItemReadName & "|" & $ConfigItemReadPrice, $ConfigItemList)
        Next
        GuiCtrlSetData($ConfigStoreName, $StoreNameRead)
        GUICtrlSetData($ConfigStorePass, $StorePassRead)
        For $i = 1 to $StoreStaffSectionRead[0][0]
            $ConfigStoreReadStaffName = $StoreStaffSectionRead[$i][0]
            $ConfigStoreReadStaffPass = $StoreStaffSectionRead[$i][1]
            GUICtrlCreateListViewItem($ConfigStoreReadStaffName & "|" & $ConfigStoreReadStaffPass, $ConfigStoreStaffList)
        Next
    EndIf

    GUISetState()

    Do
        $msg = GUIGetMsg()
        Switch $msg
            Case $ConfigItemAdd
                ConfigAddItemData()
            Case $ConfigItemRem
                ConfigRemItemData()
            Case $ConfigItemClr
                ConfigClrItemData()
            Case $ConfigStoreStaffAdd
                ConfigAddStaffData()
            Case $ConfigStoreStaffRem
                ConfigRemStaffData()
            Case $ConfigStoreStaffClr
                ConfigClrStaffData()
            Case $ConfigSaveButton
                ConfigSaveData()
            Case $ConfigClrButton
                ConfigClrData()
            Case $ConfigCancelButton
                ConfigCancelData()
        EndSwitch
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>ConfigData

Func ConfigAddItemData()
    $ConfigItemReadCode = GUICtrlRead($ConfigItemCode)
    $ConfigItemReadName = GUICtrlRead($ConfigItemName)
    $ConfigItemReadPrice = GUICtrlRead($ConfigItemDollar) & "." & GUICtrlRead($ConfigItemCents)

    GUICtrlCreateListViewItem($ConfigItemReadCode & "|" & $ConfigItemReadName & "|" & $ConfigItemReadPrice, $ConfigItemList)

    GUICtrlSetData($ConfigItemCode, "")
    GUICtrlSetData($ConfigItemName, "")
    GUICtrlSetData($ConfigItemDollar, "")
    GUICtrlSetData($ConfigItemCents, "")
EndFunc   ;==>ConfigAddItemData

Func ConfigRemItemData()
    _GUICtrlListView_DeleteItemsSelected($ConfigItemList)
EndFunc   ;==>ConfigRemItemData

Func ConfigClrItemData()
    _GUICtrlListView_DeleteAllItems($ConfigItemList)
EndFunc   ;==>ConfigClrItemData

Func ConfigAddStaffData()
    $ConfigStoreReadStaffName = GUICtrlRead($ConfigStoreStaffName)
    $ConfigStoreReadStaffPass = GUICtrlRead($ConfigStoreStaffPass)

    GUICtrlCreateListViewItem($ConfigStoreReadStaffName & "|" & $ConfigStoreReadStaffPass, $ConfigStoreStaffList)

    GUICtrlSetData($ConfigStoreStaffName, "")
    GUICtrlSetData($ConfigStoreStaffPass, "")
EndFunc   ;==>ConfigAddStaffData

Func ConfigRemStaffData()
    _GUICtrlListView_DeleteItemsSelected($ConfigStoreStaffList)
EndFunc   ;==>ConfigRemStaffData

Func ConfigClrStaffData()
    _GUICtrlListView_DeleteAllItems($ConfigStoreStaffList)
EndFunc   ;==>ConfigClrStaffData

Func ConfigSaveData()

    If FileExists($Database) Then
        FileDelete($Database)
    EndIf

    $ConfigStoreReadName = GUICtrlRead($ConfigStoreName)
    $ConfigStoreReadPass = GUICtrlRead($ConfigStorePass)

    IniWrite($Database, "General", "Name", $ConfigStoreReadName)
    IniWrite($Database, "General", "Password", $ConfigStoreReadPass)

    For $i = 0 To _GUICtrlListView_GetItemCount($ConfigItemList) - 1
        $ConfigItemReadCode = _GUICtrlListView_GetItemText($ConfigItemList, $i, 0)
        $ConfigItemReadName = _GUICtrlListView_GetItemText($ConfigItemList, $i, 1)
        $ConfigItemReadPrice = _GUICtrlListView_GetItemText($ConfigItemList, $i, 2)
        IniWrite($Database, "Items", $ConfigItemReadCode, $ConfigItemReadName & "|" & $ConfigItemReadPrice)
    Next

    For $i = 0 To _GUICtrlListView_GetItemCount($ConfigStoreStaffList) - 1
        $ConfigStoreReadStaffName = _GUICtrlListView_GetItemText($ConfigStoreStaffList, $i, 0)
        $ConfigStoreReadStaffPass = _GUICtrlListView_GetItemText($ConfigStoreStaffList, $i, 1)
        IniWrite($Database, "Staff", $ConfigStoreReadStaffName, $ConfigStoreReadStaffPass)
    Next
EndFunc   ;==>ConfigSaveData

Func ConfigClrData()
    _GUICtrlListView_DeleteAllItems($ConfigItemList)
    _GUICtrlListView_DeleteAllItems($ConfigStoreStaffList)

    GUICtrlSetData($ConfigItemCode, "")
    GUICtrlSetData($ConfigItemName, "")
    GUICtrlSetData($ConfigItemDollar, "")
    GUICtrlSetData($ConfigItemCents, "")

    GUICtrlSetData($ConfigStoreStaffName, "")
    GUICtrlSetData($ConfigStoreStaffPass, "")

    GUICtrlSetData($ConfigStoreName, "")
    GUICtrlSetData($ConfigStorePass, "")
EndFunc   ;==>ConfigClrData

Func ConfigCancelData()
    Exit
EndFunc   ;==>ConfigCancelData

Share this post


Link to post
Share on other sites

I have another AutoIt related thing to ask. Is it possible to share variables between two AutoIt Files by using #include? I keep on getting warnings like "possibly used before declaration" and "undeclared global variable" even though I have already declared them.

MainGUI.au3:-

ConfigGUI.au3:

Yes, it's possible and very common to do so. All the UDFs depend on that working.

Exactly which variables is it calling out in your examples?

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

To be honest, I don't really know what I did wrong. When you run the script "MainGUI.au3", there will be warnings saying that the variable is undeclared and when you run "ConfigGUI.au3", you cannot add/remove/clear the listview items:

MainGUI Warnings:

ConfigGUI.au3(78,23) : WARNING: $ItemSectionRead: possibly used before declaration.

If $ItemSectionRead <>

~~~~~~~~~~~~~~~~~~~~^

ConfigGUI.au3(87,50) : WARNING: $StoreNameRead: possibly used before declaration.

GUICtrlSetData($ConfigStoreName, $StoreNameRead)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

ConfigGUI.au3(88,50) : WARNING: $StorePassRead: possibly used before declaration.

GUICtrlSetData($ConfigStorePass, $StorePassRead)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

ConfigGUI.au3(89,29) : WARNING: $StoreStaffSectionRead: possibly used before declaration.

If $StoreStaffSectionRead <>

~~~~~~~~~~~~~~~~~~~~~~~~~~^

MainGUI.au3 - 0 error(s), 4 warning(s)

ConfigGUI Errors:

ConfigGUI.au3 (126) : ==> Variable used without being declared.:

$ConfigItemReadCode = GUICtrlRead($ConfigItemCode)

$ConfigItemReadCode = GUICtrlRead(^ ERROR

MainGUI.au3:- Updated

#include-once

#include <GuiConstantsEx.au3>
#include <ConfigGUI.au3>

;Credits:
;
;SmOke_N for reading the text in the list view and exporting it into an INI
;Melba23 for the checkbox mask and unmask the $ES_PASSWORD

Global $ItemSectionRead, $StoreStaffSectionRead, $StoreNameRead, $StorePassRead
Global $Database = "Database.ini"

If Not FileExists($Database) Then
    FIRSTRUN()
Else
    RetrieveData()
    ConfigData(1)
EndIf

Func FIRSTRUN()
    $CreateData = MsgBox(36, "Program Name", "This seems to be your first time running this progam." & @CRLF & "Do you want to create and configure your Database?")
    If $CreateData = 6 Then
        ConfigData()
    ElseIf $CreateData = 7 Then
        Exit
    EndIf
EndFunc   ;==>FirstRun

Func RetrieveData()
    $ItemSectionRead = IniReadSection($Database, "Items")
    $StoreStaffSectionRead = IniReadSection($Database, "Staff")
    $StoreNameRead = IniRead($Database, "General", "Name", "")
    $StorePassRead = IniRead($Database, "General", "Name", "")
EndFunc   ;==>RetrieveData

ConfigGUI.au3:- Updated

#include-once

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>
#include <MainGUI.au3>

Global $ConfigItemCode, $ConfigItemName, $ConfigItemDollar, $ConfigItemCents
Global $ConfigItemList, $ConfigStoreStaffList
Global $ConfigStoreStaffName, $ConfigStoreStaffPass, $ConfigStoreName, $ConfigStorePass
Global $Database = "Database.ini"

Func ConfigData($Data = 0)

    $ConfigGUI = GUICreate("Database Configuration", 660, 530)

    GUICtrlCreateGroup("", 5, 0, 650, 480)

    $ConfigItemList = GUICtrlCreateListView("Barcode |Item Name |Price", 15, 15, 305, 360, $LVS_REPORT)
    _GUICtrlListView_SetColumnWidth($ConfigItemList, 0, 70)
    _GUICtrlListView_SetColumnWidth($ConfigItemList, 1, 160)
    _GUICtrlListView_SetColumnWidth($ConfigItemList, 2, 70)

    GUICtrlCreateLabel("Item Name:", 15, 385, 60, 20)
    GUICtrlCreateLabel("Barcode:", 15, 415, 60, 20)
    GUICtrlCreateLabel("Price:", 170, 415, 60, 20)

    $ConfigItemName = GUICtrlCreateInput("", 80, 385, 240, 20)

    $ConfigItemCode = GUICtrlCreateInput("", 80, 415, 80, 20, $ES_NUMBER)

    $ConfigItemDollar = GUICtrlCreateInput("", 240, 415, 45, 20, $ES_NUMBER)
    GUICtrlCreateLabel(".", 287, 415, 20, 12)
    $ConfigItemCents = GUICtrlCreateInput("", 295, 415, 25, 20, $ES_NUMBER)

    GUICtrlSetLimit($ConfigItemCode, 8, 8)
    GUICtrlSetLimit($ConfigItemName, 20, 0)
    GUICtrlSetLimit($ConfigItemDollar, 4, 0)
    GUICtrlSetLimit($ConfigItemCents, 2, 0)

    $ConfigItemAdd = GUICtrlCreateButton("Add", 30, 445, 80, 25)
    $ConfigItemRem = GUICtrlCreateButton("Remove", 125, 445, 80, 25)
    $ConfigItemClr = GUICtrlCreateButton("Clear", 220, 445, 80, 25)

    GUICtrlCreateLabel("", 330, 6, 1, 473, 0x08001000)

    GUICtrlCreateLabel("Company Name:", 340, 20, 80, 20)
    GUICtrlCreateLabel("Admin Pass:", 340, 50, 80, 20)
    GUICtrlCreateLabel("Staff Name:", 340, 385, 80, 20)
    GUICtrlCreateLabel("Staff Pass:", 340, 415, 80, 20)

    $ConfigStoreStaffList = GUICtrlCreateListView("Staff Name |Staff Password", 340, 90, 305, 285, $LVS_REPORT)
    _GUICtrlListView_SetColumnWidth($ConfigStoreStaffList, 0, 160)
    _GUICtrlListView_SetColumnWidth($ConfigStoreStaffList, 1, 140)

    $ConfigStoreName = GUICtrlCreateInput("", 425, 20, 220, 20)
    $ConfigStorePass = GUICtrlCreateInput("", 425, 50, 220, 20)

    GUICtrlCreateLabel("", 329, 80, 327, 1, 0x08001000)

    $ConfigStoreStaffName = GUICtrlCreateInput("", 425, 385, 220, 20)
    $ConfigStoreStaffPass = GUICtrlCreateInput("", 425, 415, 220, 20)

    GUICtrlSetLimit($ConfigStoreName, 20, 0)
    GUICtrlSetLimit($ConfigStorePass, 20, 0)
    GUICtrlSetLimit($ConfigStoreStaffName, 20, 0)
    GUICtrlSetLimit($ConfigStoreStaffPass, 20, 0)

    $ConfigStoreStaffAdd = GUICtrlCreateButton("Add", 355, 445, 80, 25)
    $ConfigStoreStaffRem = GUICtrlCreateButton("Remove", 450, 445, 80, 25)
    $ConfigStoreStaffClr = GUICtrlCreateButton("Clear", 545, 445, 80, 25)

    $ConfigSaveButton = GUICtrlCreateButton("Save", 190, 495, 80, 25)
    $ConfigClrButton = GUICtrlCreateButton("Clear All", 290, 495, 80, 25)
    $ConfigCancelButton = GUICtrlCreateButton("Cancel", 390, 495, 80, 25)

    If $Data = 1 Then
        If $ItemSectionRead <> 1 Then
            For $i = 1 To $ItemSectionRead[0][0]
                $ConfigItemReadCode = $ItemSectionRead[$i][0]
                $ConfigItemNamePrice = StringSplit($ItemSectionRead[$i][1], "|")
                $ConfigItemReadName = $ConfigItemNamePrice[1]
                $ConfigItemReadPrice = $ConfigItemNamePrice[2]
                GUICtrlCreateListViewItem($ConfigItemReadCode & "|" & $ConfigItemReadName & "|" & $ConfigItemReadPrice, $ConfigItemList)
            Next
        EndIf
        GUICtrlSetData($ConfigStoreName, $StoreNameRead)
        GUICtrlSetData($ConfigStorePass, $StorePassRead)
        If $StoreStaffSectionRead <> 1 Then
            For $i = 1 To $StoreStaffSectionRead[0][0]
                $ConfigStoreReadStaffName = $StoreStaffSectionRead[$i][0]
                $ConfigStoreReadStaffPass = $StoreStaffSectionRead[$i][1]
                GUICtrlCreateListViewItem($ConfigStoreReadStaffName & "|" & $ConfigStoreReadStaffPass, $ConfigStoreStaffList)
            Next
        EndIf
    EndIf

    GUISetState()

    Do
        $msg = GUIGetMsg()
        Switch $msg
            Case $ConfigItemAdd
                ConfigAddItemData()
            Case $ConfigItemRem
                ConfigRemItemData()
            Case $ConfigItemClr
                ConfigClrItemData()
            Case $ConfigStoreStaffAdd
                ConfigAddStaffData()
            Case $ConfigStoreStaffRem
                ConfigRemStaffData()
            Case $ConfigStoreStaffClr
                ConfigClrStaffData()
            Case $ConfigSaveButton
                ConfigSaveData()
            Case $ConfigClrButton
                ConfigClrData()
            Case $ConfigCancelButton
                ConfigCancelData()
        EndSwitch
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>ConfigData

Func ConfigAddItemData()
    $ConfigItemReadCode = GUICtrlRead($ConfigItemCode)
    $ConfigItemReadName = GUICtrlRead($ConfigItemName)
    $ConfigItemReadPrice = GUICtrlRead($ConfigItemDollar) & "." & GUICtrlRead($ConfigItemCents)

    $ConfigItemCheckCode = _GUICtrlListView_FindText($ConfigItemList, $ConfigItemReadCode)
    $ConfigItemCheckName = _GUICtrlListView_FindInText($ConfigItemList, $ConfigItemReadName)

    If $ConfigItemCheckCode <> -1 Then
        MsgBox(48, "Program Name", "Sorry, the Barcode you have specified already exists.")
        _GUICtrlListView_EnsureVisible($ConfigItemList, $ConfigItemCheckCode)
    Else
        If $ConfigItemCheckName <> -1 Then
            MsgBox(48, "Program Name", "Sorry, the Item Name you have specified already exists.")
            _GUICtrlListView_EnsureVisible($ConfigItemList, $ConfigItemCheckName)
        Else
            If $ConfigItemReadName = "" Then
                MsgBox(48, "Program Name", "Sorry, the Item Name cannot be left blank.")
            Else
                If StringLen($ConfigItemReadCode) <> 8 Then
                    MsgBox(48, "Program Name", "Sorry, the Barcode must be 8 characters long.")
                Else
                    If $ConfigItemReadPrice = "." Then
                        $ConfigItemReadPrice = "0.00"
                    ElseIf GUICtrlRead($ConfigItemDollar) = "" Then
                        $ConfigItemReadPrice = "0." & GUICtrlRead($ConfigItemCents)
                    ElseIf GUICtrlRead($ConfigItemCents) = "" Then
                        $ConfigItemReadPrice = GUICtrlRead($ConfigItemDollar) & ".00"
                    EndIf

                    If StringLen(GUICtrlRead($ConfigItemCents)) = 1 Then
                        $ConfigItemReadPrice = GUICtrlRead($ConfigItemDollar) & "." & GUICtrlRead($ConfigItemCents) & "0"
                    EndIf

                    GUICtrlCreateListViewItem($ConfigItemReadCode & "|" & $ConfigItemReadName & "|" & $ConfigItemReadPrice, $ConfigItemList)

                    GUICtrlSetData($ConfigItemCode, "")
                    GUICtrlSetData($ConfigItemName, "")
                    GUICtrlSetData($ConfigItemDollar, "")
                    GUICtrlSetData($ConfigItemCents, "")
                EndIf
            EndIf
        EndIf
    EndIf
EndFunc   ;==>ConfigAddItemData

Func ConfigRemItemData()
    _GUICtrlListView_DeleteItemsSelected($ConfigItemList)
EndFunc   ;==>ConfigRemItemData

Func ConfigClrItemData()
    _GUICtrlListView_DeleteAllItems($ConfigItemList)
EndFunc   ;==>ConfigClrItemData

Func ConfigAddStaffData()
    $ConfigStoreReadStaffName = GUICtrlRead($ConfigStoreStaffName)
    $ConfigStoreReadStaffPass = GUICtrlRead($ConfigStoreStaffPass)

    $ConfigStoreCheckStaffName = _GUICtrlListView_FindText($ConfigStoreStaffList, $ConfigStoreReadStaffName)

    If $ConfigStoreCheckStaffName <> -1 Then
        MsgBox(48, "Program Name", "Sorry, the Staff Name you specified already exists.")
        _GUICtrlListView_EnsureVisible($ConfigStoreStaffList, $ConfigStoreCheckStaffName)
    Else
        If $ConfigStoreReadStaffName = "" Then
            MsgBox(48, "Program Name", "Sorry, the Staff Name cannot be left blank.")
        EndIf
    EndIf

    GUICtrlCreateListViewItem($ConfigStoreReadStaffName & "|" & $ConfigStoreReadStaffPass, $ConfigStoreStaffList)

    GUICtrlSetData($ConfigStoreStaffName, "")
    GUICtrlSetData($ConfigStoreStaffPass, "")
EndFunc   ;==>ConfigAddStaffData

Func ConfigRemStaffData()
    _GUICtrlListView_DeleteItemsSelected($ConfigStoreStaffList)
EndFunc   ;==>ConfigRemStaffData

Func ConfigClrStaffData()
    _GUICtrlListView_DeleteAllItems($ConfigStoreStaffList)
EndFunc   ;==>ConfigClrStaffData

Func ConfigSaveData()

    If FileExists($Database) Then
        FileDelete($Database)
    EndIf

    $ConfigStoreReadName = GUICtrlRead($ConfigStoreName)
    $ConfigStoreReadPass = GUICtrlRead($ConfigStorePass)

    IniWrite($Database, "General", "Name", $ConfigStoreReadName)
    IniWrite($Database, "General", "Password", $ConfigStoreReadPass)

    For $i = 0 To _GUICtrlListView_GetItemCount($ConfigItemList) - 1
        $ConfigItemReadCode = _GUICtrlListView_GetItemText($ConfigItemList, $i, 0)
        $ConfigItemReadName = _GUICtrlListView_GetItemText($ConfigItemList, $i, 1)
        $ConfigItemReadPrice = _GUICtrlListView_GetItemText($ConfigItemList, $i, 2)
        IniWrite($Database, "Items", $ConfigItemReadCode, $ConfigItemReadName & "|" & $ConfigItemReadPrice)
    Next

    For $i = 0 To _GUICtrlListView_GetItemCount($ConfigStoreStaffList) - 1
        $ConfigStoreReadStaffName = _GUICtrlListView_GetItemText($ConfigStoreStaffList, $i, 0)
        $ConfigStoreReadStaffPass = _GUICtrlListView_GetItemText($ConfigStoreStaffList, $i, 1)
        IniWrite($Database, "Staff", $ConfigStoreReadStaffName, $ConfigStoreReadStaffPass)
    Next
EndFunc   ;==>ConfigSaveData

Func ConfigClrData()
    _GUICtrlListView_DeleteAllItems($ConfigItemList)
    _GUICtrlListView_DeleteAllItems($ConfigStoreStaffList)

    GUICtrlSetData($ConfigItemCode, "")
    GUICtrlSetData($ConfigItemName, "")
    GUICtrlSetData($ConfigItemDollar, "")
    GUICtrlSetData($ConfigItemCents, "")

    GUICtrlSetData($ConfigStoreStaffName, "")
    GUICtrlSetData($ConfigStoreStaffPass, "")

    GUICtrlSetData($ConfigStoreName, "")
    GUICtrlSetData($ConfigStorePass, "")
EndFunc   ;==>ConfigClrData

Func ConfigCancelData()
    Exit
EndFunc   ;==>ConfigCancelData

Share this post


Link to post
Share on other sites

BoonPek,

You get the errors because you are using varibles defined in MainGUI.au3 in ConfigGUI.au3. As you are including ConfigGUI.au3 in MainGUI.au3, the variables appear in the script at the point you have the #include line - and that is before the variable declaration. :)

Solution: Move the variable declaration to ABOVE the #include line. That way you get the variables declared BEFORE the include file and all should work without problem (well, it does for me!). ;)

M23

P.S. Why do you have MainGUI.au3 as an #include in ConfigGUI.au3? You should have it as a main script. ;)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thank you again Melba23! You have been very helpful to me ;)


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