Sign in to follow this  
Followers 0
Aceguy

saving Combo list

10 posts in this topic

when i click my save button. it doesnt save the list box.

GLOBAL $info

#include <GuiConstants.au3>

GuiCreate("MyGUI", 191, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$GO=GUICtrlCreateButton("read",5,5,60,20)

$List_1 = GuiCtrlCreateList("", 40, 40, 110, 201,BitOR($WS_BORDER, $WS_VSCROLL))

$input_box= GUICtrlCreateInput("",5,230,75,30)

$save=GUICtrlCreateButton("Save list",5,280,50,30)

GuiSetState()

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $MSG = $GO

$var = IniReadSection("c:\documents and settings\ace\desktop\recipies.ini","recipies")

For $i = 1 To $var[0][0]

if $var[$i][1] = $info Then

MsgBox(0,"","got it")

endif

GUICtrlSetData($List_1,$var[$i][1]&"|")

Next

case $msg=$save

IniWrite("c:\documents and settings\ace\desktop\recipies.ini",GUICtrlRead($List_1),GUICtrlRead($List_1),GUICtrlRead($List_1))

EndSelect

WEnd

Exit

please help.

Share this post


Link to post
Share on other sites



3 quick things...

1. Welcome to the forums

2. Please use code tags [ code] [ /code] (without spaces) when showing code

3. recipies is recipes :D

Now...

If your going to provide some code, please make it workable, you have a var in there "$info" that has no declaration... Also

IniWrite("c:\documents and settings\ace\desktop\recipies.ini",GUICtrlRead($List_1),GUICtrlRead($List_1),GUICtrlRead($List_1))

Your saving the list under the same "Section"/"Key"/and "Value"... but your reading section called "recipies"?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

And also why :

$input_box= GUICtrlCreateInput("",5,230,75,30)

and the $input_box is not used in the script ??


D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper

Share this post


Link to post
Share on other sites

ok, sorry, newbie to this.

ok, here goes, everthing is ok but when i try to save the listbox, its wrong.

Please help.

#include <GuiConstants.au3>

GUICreate("MyGUI", 191, 316, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$List_1 = GUICtrlCreateList("", 40, 40, 110, 201, BitOR($WS_BORDER, $WS_VSCROLL))
$input_box = GUICtrlCreateInput("", 5, 230, 75, 30)
$save = GUICtrlCreateButton("Save list", 5, 280, 50, 30)
$var = IniReadSection("c:\documents and settings\ace\desktop\recipies.ini", "recipies")
$add = GUICtrlCreateButton("Add to list", 100, 240, 50, 20)

For $i = 1 To $var[0][0]
    
    
    GUICtrlSetData($List_1, $var[$i][1] & "|")
Next
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $save
            $in = GUICtrlRead($List_1)
            IniWrite("c:\documents and settings\ace\desktop\recipies.ini", "recipies", "key", GUICtrlRead($in))
        Case $msg = $add
            $in = GUICtrlRead($input_box)
            GUICtrlSetData($List_1, $in & "|")
    EndSelect
WEnd
Exit

Many thanks.

Share this post


Link to post
Share on other sites

Care to elaborate on "what" goes wrong?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You shouldn't have the same "key" name everytime, otherwise the result will never be right... GUICtrlRead() with GUICtrlCreateList() only works if you click on the item in the list box or you will get a blank result... I've made a work around with some comments to fix your current issues, and potential ones... please study them.

#include <GuiConstants.au3>
Dim $MyIni = @DesktopDir & "\recipies.ini", $StoreInfo = '', $IniKeyCount = 0 ; $MyIni using macros solves an issue of others not being able to make it work on their computers
If Not FileExists($MyIni) Then FileWriteLine($MyIni, '[recipies]') ; If the file doesn't exist, let's make one

$MyGUI = GUICreate("MyGUI", 191, 316, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) ; Get in the habbit of always giving your GUI a variable name to store the handle

$List_1 = GUICtrlCreateList("", 40, 40, 110, 201, BitOR($WS_BORDER, $WS_VSCROLL))
$input_box = GUICtrlCreateInput("", 5, 230, 75, 30)
$save = GUICtrlCreateButton("Save list", 5, 280, 50, 30)
$var = IniReadSection($MyIni, "recipies")
$add = GUICtrlCreateButton("Add to list", 100, 240, 50, 20)

If IsArray($var) Then ; Lets make sure it's actually formatted or we will throw an error
    $IniKeyCount = $var[0][0]
    For $i = 1 To $var[0][0]
        GUICtrlSetData($List_1, $var[$i][1] & "|")
    Next
EndIf

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $save
            If $StoreInfo <> '' Then
                $Array = StringSplit(StringTrimRight($StoreInfo, 1), '|')
                For $xcount = 1 To UBound($Array) - 1
                    IniWrite($MyIni, "recipies", $IniKeyCount + $xcount, $Array[$xcount]) ; $IniKeyCount = the key number / $array[$xcount] = the items that were read
                Next
                $StoreInfo = '' ; After we've written to the ini let's erase the contents so we don't have duplicates
                $IniKeyCount = $IniKeyCount + UBound($array) - 1 ; Lets re-add the new amount to the inicount we had before for the keys...that way we don't have to do another inireadsection
            EndIf
        Case $msg = $add
            $in = GUICtrlRead($input_box)
            GUICtrlSetData($List_1, $in & "|")
            $StoreInfo = $StoreInfo & $in & '|' ;Since the "List Box" must be clicked to be read with GUICtrlRead() we will store the information everytime you click add
    EndSelect
WEnd
Exit

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Maybe you should try Valuaters Welcome to AutoIt 123... it may give you better grasp on things now and to come.

http://www.autoitscript.com/forum/index.php?showtopic=21048


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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