Jump to content

help with saveing listview into .ini


CodyBarrett
 Share

Recommended Posts

yes how do i save what the user has put in the listview box into a .ini file i have tried numerous things.... also once i figure out that.... loading into listview box from ini might be alittle helpfull :mellow: here is my code so far please tell me whatswrong

;This is made by BOB
;(bob00037 on the autoitforums)
; This script Is An Information Organizer For The Not Very Widely Known MMORPG Endless Online;
#include <GuiConstantsEx.au3>
#Include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <GuiConstants.au3>

DirCreate("C:\GUILDINFO")
If FileExists("C:\guildinfo\Guild.ini") Then
    
Else
    MsgBox(64,"no", "Does NOT exists")
    IniWrite("C:\GUILDINFO\Guild.ini", "Help", "#", "*****this is a help guide on the controlls of GI******                                                   #[For Each editbox hitting ENTER will call a function]                                  #[top right [X]=exit\OR\ ALT+f4=exit]                              #[CANNOT edit the list box BUT just add a member then Delete it when you need to edit it, then ad again]                                                                                             #[DO NOT change the directory outputs (i have not designed it to be user friendly)]")
    IniWrite("C:\guildinfo\Guild.ini", "Personal", "#Text", "0")
    IniWrite("C:\guildinfo\Guild.ini", "Members", "#Current", "0")
    iniwrite("C:\guildinfo\Guild.ini", "Members", "#Old", "0")
    IniWrite("C:\guildinfo\Guild.ini", "Rules", "#Rule", "0")
    MsgBox(64,"NOW", "it exists")
    
    
EndIf
#region ; GLOBAL VARS
Global $GUI, $Pdt, $PSv, $Ldbtn, $Pdtdr, $INIp, $OpnDrb, $OpnDrI, $hlp, $INIh,$Delcm, $AdRcm, $Adrcm2, $Addcm, $listview, $Listview2, $INIcm, $Cmdt, $Cmld, $listedit, $CmSv, $Cmsv2, $CmSv3, $CmLd, $CmLd2, $CmLd3
#EndRegion 



#region; GUI
$GUI = GuiCreate("GI [Guild Information]", 400, 400)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)
#EndRegion


#Region ; PIC
GuiCtrlCreatePic("guild.bmp",0,0, 399,79)
#EndRegion


#Region ; Personal TAB
GuiCtrlCreateTab(0, 80)
GuiCtrlCreateTabItem("Personal")


_vars()
Func _vars()
    $PSv = GuiCtrlCreateButton("SAVE", 0, 360, 400, 20); The "save" button on the personal tab
    $OpnDrB = GuiCtrlCreateButton("OPEN DIR", 300, 315, 100, 20);  The "OPEN" button on the personal tab
    $Ldbtn = GUICtrlCreateButton("LOAD", 300, 335,100,20); The "load" button on the personal tab
    $hlp = GUICtrlCreateButton("HELP", 200, 380, 200,20); HELP button for the help file
    $Pdtdr = GUICtrlCreateInput("C:\guildinfo\guild.ini", 0, 335, 300, 20); The DIRECTORY input for LOAD on the personal tab
    $Pdt = GUICtrlCreateEdit(" ", 0, 130, 400, 175, 0x0004);The BIG input on the personal tab
    $OpnDrI = GUICtrlCreateInput("C:\guildinfo", 0, 315, 300, 20); The DIRECTORY input for OPEN DIR on the personal tab
    $INIp = IniRead("Guild.ini", "personal", "#text", ""); The [personal] .ini text readback call
    $INIh = IniRead("Guild.ini", "Help", "#", ""); The [help] .ini text readback call
EndFunc

; DATE
#Region
GuiCtrlCreateDate("", 0, 380, 200, 20)
#EndRegion
#EndRegion


#Region ;Guild TAB
GuiCtrlCreateTab(0, 80)
GuiCtrlCreateTabItem("Guild")

#Region ; DATE
GuiCtrlCreateDate("", 0, 380, 200, 20)
#EndRegion


#Region
 _vars2()
Func _vars2()
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)  ; to allow drag and dropping
    $Adrcm = GuiCtrlCreateInput("Name|0|0|0|0", 0, 110, 224, 20)
    $Delcm = GuiCtrlCreateButton("Delete", 306, 110, 80, 20)
    $Addcm = GuiCtrlCreateButton("Add ", 226, 110, 80, 20)
    $listview = GuiCtrlCreateListView("           Member              |Rank|Warnings|Test Taken|Gone", 0, 131, 399, 227, BitOR($LVS_EDITLABELS, $LVS_EX_GRIDLINES))
    $Listview2 = GUICtrlRead($listview)
    $Adrcm2 = GUICtrlRead( $Adrcm )
    $CmSv = GUICtrlCreateButton("SAVE", 0, 360, 197, 18)
    $Cmld = GUICtrlCreateButton("LOAD", 198, 360, 200, 18)
    
EndFunc
#EndRegion
#EndRegion

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $PSv
            MsgBox(0,"SAVE?",GUICtrlRead($Pdt))
            Iniwrite("guild.ini", "personal", "#text", GUICtrlRead($Pdt))
        Case $Ldbtn
            GUICtrlSetData ( $Pdt, $INIp )
        Case $OpnDrB
            MsgBox( 0, "OPEN?", "UDF Directory" )
        Case $hlp
            MsgBox(0,"Help?", "UDF file",GUICtrlRead($Pdtdr))
            GUICtrlSetData ( $Pdt, $INIh )
        Case $Addcm
            GUICtrlCreateListViewItem( GUICtrlRead( $Adrcm ), $listview)
        Case $Delcm
            _GUICtrlListView_DeleteItemsSelected($Listview)
        Case $CmSv
            $CmSv2 = FileSaveDialog( "SAVE", "C:\GUILDINFO\", "(*.ini*)", "guild.ini", "guild.ini")
            IniWrite($CmSv2, "Members", "#current", $listview2)
        Case $Cmld
            $CmLd2 = FileOpenDialog ( "LOAD", "C:\Guildinfo\", "(*.ini*)", "Guild.ini" , "Guild.ini" )
            
            iniread($CmLd2, "Members", "#curent", "NotFound")
    EndSwitch

; GUI MESSAGE LOOP

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
Edited by bob00037
Link to comment
Share on other sites

yes how do i save what the user has put in the listview box into a .ini file i have tried numerous things.... also once i figure out that.... loading into listview box from ini might be alittle helpfull :mellow: here is my code so far please tell me whatswrong

;This is made by BOB
;(bob00037 on the autoitforums)
; This script Is An Information Organizer For The Not Very Widely Known MMORPG Endless Online;
#include <GuiConstantsEx.au3>
#Include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <GuiConstants.au3>

DirCreate("C:\GUILDINFO")
If FileExists("C:\guildinfo\Guild.ini") Then
    
Else
    MsgBox(64,"no", "Does NOT exists")
    IniWrite("C:\GUILDINFO\Guild.ini", "Help", "#", "*****this is a help guide on the controlls of GI******                                                   #[For Each editbox hitting ENTER will call a function]                                  #[top right [X]=exit\OR\ ALT+f4=exit]                              #[CANNOT edit the list box BUT just add a member then Delete it when you need to edit it, then ad again]                                                                                             #[DO NOT change the directory outputs (i have not designed it to be user friendly)]")
    IniWrite("C:\guildinfo\Guild.ini", "Personal", "#Text", "0")
    IniWrite("C:\guildinfo\Guild.ini", "Members", "#Current", "0")
    iniwrite("C:\guildinfo\Guild.ini", "Members", "#Old", "0")
    IniWrite("C:\guildinfo\Guild.ini", "Rules", "#Rule", "0")
    MsgBox(64,"NOW", "it exists")
    
    
EndIf
#region; GLOBAL VARS
Global $GUI, $Pdt, $PSv, $Ldbtn, $Pdtdr, $INIp, $OpnDrb, $OpnDrI, $hlp, $INIh,$Delcm, $AdRcm, $Adrcm2, $Addcm, $listview, $Listview2, $INIcm, $Cmdt, $Cmld, $listedit, $CmSv, $Cmsv2, $CmSv3, $CmLd, $CmLd2, $CmLd3
#EndRegion 



#region; GUI
$GUI = GuiCreate("GI [Guild Information]", 400, 400)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)
#EndRegion


#Region; PIC
GuiCtrlCreatePic("guild.bmp",0,0, 399,79)
#EndRegion


#Region; Personal TAB
GuiCtrlCreateTab(0, 80)
GuiCtrlCreateTabItem("Personal")


_vars()
Func _vars()
    $PSv = GuiCtrlCreateButton("SAVE", 0, 360, 400, 20); The "save" button on the personal tab
    $OpnDrB = GuiCtrlCreateButton("OPEN DIR", 300, 315, 100, 20);  The "OPEN" button on the personal tab
    $Ldbtn = GUICtrlCreateButton("LOAD", 300, 335,100,20); The "load" button on the personal tab
    $hlp = GUICtrlCreateButton("HELP", 200, 380, 200,20); HELP button for the help file
    $Pdtdr = GUICtrlCreateInput("C:\guildinfo\guild.ini", 0, 335, 300, 20); The DIRECTORY input for LOAD on the personal tab
    $Pdt = GUICtrlCreateEdit(" ", 0, 130, 400, 175, 0x0004);The BIG input on the personal tab
    $OpnDrI = GUICtrlCreateInput("C:\guildinfo", 0, 315, 300, 20); The DIRECTORY input for OPEN DIR on the personal tab
    $INIp = IniRead("Guild.ini", "personal", "#text", ""); The [personal] .ini text readback call
    $INIh = IniRead("Guild.ini", "Help", "#", ""); The [help] .ini text readback call
EndFunc

; DATE
#Region
GuiCtrlCreateDate("", 0, 380, 200, 20)
#EndRegion
#EndRegion


#Region;Guild TAB
GuiCtrlCreateTab(0, 80)
GuiCtrlCreateTabItem("Guild")

#Region; DATE
GuiCtrlCreateDate("", 0, 380, 200, 20)
#EndRegion


#Region
 _vars2()
Func _vars2()
    GUICtrlSetState(-1, $GUI_DROPACCEPTED); to allow drag and dropping
    $Adrcm = GuiCtrlCreateInput("Name|0|0|0|0", 0, 110, 224, 20)
    $Delcm = GuiCtrlCreateButton("Delete", 306, 110, 80, 20)
    $Addcm = GuiCtrlCreateButton("Add ", 226, 110, 80, 20)
    $listview = GuiCtrlCreateListView("           Member              |Rank|Warnings|Test Taken|Gone", 0, 131, 399, 227, BitOR($LVS_EDITLABELS, $LVS_EX_GRIDLINES))
    $Listview2 = GUICtrlRead($listview)
    $Adrcm2 = GUICtrlRead( $Adrcm )
    $CmSv = GUICtrlCreateButton("SAVE", 0, 360, 197, 18)
    $Cmld = GUICtrlCreateButton("LOAD", 198, 360, 200, 18)
    
EndFunc
#EndRegion
#EndRegion

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $PSv
            MsgBox(0,"SAVE?",GUICtrlRead($Pdt))
            Iniwrite("guild.ini", "personal", "#text", GUICtrlRead($Pdt))
        Case $Ldbtn
            GUICtrlSetData ( $Pdt, $INIp )
        Case $OpnDrB
            MsgBox( 0, "OPEN?", "UDF Directory" )
        Case $hlp
            MsgBox(0,"Help?", "UDF file",GUICtrlRead($Pdtdr))
            GUICtrlSetData ( $Pdt, $INIh )
        Case $Addcm
            GUICtrlCreateListViewItem( GUICtrlRead( $Adrcm ), $listview)
        Case $Delcm
            _GUICtrlListView_DeleteItemsSelected($Listview)
        Case $CmSv
            $CmSv2 = FileSaveDialog( "SAVE", "C:\GUILDINFO\", "(*.ini*)", "guild.ini", "guild.ini")
            IniWrite($CmSv2, "Members", "#current", $listview2)
        Case $Cmld
            $CmLd2 = FileOpenDialog ( "LOAD", "C:\Guildinfo\", "(*.ini*)", "Guild.ini" , "Guild.ini" )
            
            iniread($CmLd2, "Members", "#curent", "NotFound")
    EndSwitch

; GUI MESSAGE LOOP

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
First get rid of the second switch GUIGetMsg loop which is a mistake.

To save the items

$Cmsv2 = FileSaveDialog("SAVE", "C:\GUILDINFO\", "(*.ini*)", "guild.ini", "guild.ini")
            if FileExists($cmsv2) then IniDelete($cmsv2,"listviewitems")
            IniWrite($cmsv2,"listviewitems","ItemCount",_GUICtrlListView_GetItemCount($listview))
            For $n = 0 To _GUICtrlListView_GetItemCount($listview) - 1
                $Itemtext = _GUICtrlListView_GetItemText($listview, $n)
                For $p = 1 To 5;for each column
                    $Itemtext &= '|' & _GUICtrlListView_GetItemText($listview, $n,$p)
                Next
                IniWrite($cmsv2,"listviewitems",$n,$Itemtext)
            Next
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

holy crap... thank you man... now how do i load? basically samething except reverse the script func?

Link to comment
Share on other sites

holy crap... thank you man...

NP.

now how do i load? basically samething except reverse the script func?

yes, have a go.

I put the number of items there so you know how many to read back. Seeing what you have done so far I know you can work it out yourself.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

lol :mellow: but when im doing a GET listitems from the .ini how do i say that thre is an unknown amount of listitems

EDITED huh today might be one of my bad days or i just cant figure out to load into the listview x'O what am i missing in this code for the button "LOAD"

Case $CmLd
            if FileExists($CmLd2) Then $Cmldini = IniRead ($CmLd2, "CurrentMembers")
            For $n = 0 To _GUICtrlListView_GetItemCount($listview) - 1
                $Itemtext = _GUICtrlListView_GetItemText($listview, $n)
                For $p = 1 To 5;for each column
                    $Itemtext &= '|' & _GUICtrlListView_GetItemText($listview, $n,$p)
                Next
                GUICtrlCreateListViewItem("", $listview)
            Next
Edited by bob00037
Link to comment
Share on other sites

lol :mellow: but when im doing a GET listitems from the .ini how do i say that thre is an unknown amount of listitems

? You don't have an unknown number of list items.

now tested

Case $Cmld
            $CmLd2 = FileOpenDialog("LOAD", "C:\Guildinfo\", "(*.ini*)", "Guild.ini", "Guild.ini")

            $NoItems = Number(IniRead($CmLd2, "listviewitems", "ItemCount", ""));I wrote the information there so you would know .
            ConsoleWrite("it conunt = " & $NoItems & @CRLF)
            For $n = 0 To $NoItems - 1
                GUICtrlCreateListViewItem(IniRead($CmLd2, "listviewitems", $n, ""),$listview);and I formatted the information nicely so you could do this
            Next

Now you've gone and ruined it all, and I had such faith in you. :(

EDIT: Corrected and tested.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

? You don't have an unknown number of list items.

not tested

CODE

$NoItems = Number(IniRead($cmsv2,"listviewitems","ItemCount",""));I wrote the information there so you would know .
For $n = 1 to $NoItems
     GUICtrlCreateListViewItem( (IniRead($cmsv2,"listviewitems", $n,"");and I formatted the information nicely so you could do this
next

Now you've gone and ruined it all, and I had such faith in you.

awwwww lol i shall try your code good sir.. and ps. it seems this seems to be one of my bad days lol
Link to comment
Share on other sites

doesnt work.... i also added a few brackets where you forgot em at the end of GUICTRLCREATELTVIEWITEM...... but still nothing. may be i should repost in a fw days when i get myhead together... meantimecan you fixit LOL :mellow:

EDiT

yeah alright ill get back to you guys on this subject in a few days... :\

Edited by bob00037
Link to comment
Share on other sites

doesnt work.... i also added a few brackets where you forgot em at the end of GUICTRLCREATELTVIEWITEM...... but still nothing. may be i should repost in a fw days when i get myhead together... meantimecan you fixit LOL :mellow:

EDiT

yeah alright ill get back to you guys on this subject in a few days... :\

I should have tested it rather than just write it down. I have corrected it now and it has been tested.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

BACK... yeah it might have been helpfull but idc i found a way i manually put in the GUIctcreatelistviewitem(iniread("guild.ini", "CurrentMembers", "1", "')) lol took a while but i got 300 of the manual ini reads and it DOEs work... if you want me to post my code i warn you its long, but no lagg. anyway could there be a more efiient way? if not im satisfied with my working one. BTW thank you so much for showing me how to save (i couldnt load anything if you ddnt) :mellow:

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...