Sign in to follow this  
Followers 0
ashley

Load and save stuff in gui

9 posts in this topic

Ok well... I have it made it save... but how do I make it load the stuff?

And it must load different things on different dates...

here is my code:

#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>

; $'s and global's:
$File = FileRead(@ScriptDir & "Dairyfile.mdf")
$fileopen = FileOpen($File, 1)
$Fileclose = FileClose($File)

If FileExists("Dairyfile.mdf") then 
    Sleep(1000)
Else
    FileWrite("Dairyfile.mdf","")
EndIf

#Region ### START Koda GUI section ### Form=
$Calander = GUICreate("Calander", 724, 550)
$MonthCal1 = GUICtrlCreateMonthCal("", 8, 8, 231, 164)
$Progress1 = GUICtrlCreateProgress(8, 176, 230, 17)
;Daily notes
$DNLabel = GUICtrlCreateLabel("Daily notes", 8, 200, 233, 17)
$Dailynotes = GUICtrlCreateEdit("", 8, 220, 233, 280)
GUICtrlSetData(-1, "")
$savebutton = GUICtrlCreateButton("Save", 8, 505, 60, 25)
$loadbutton = GUICtrlCreateButton("Load", 70, 505, 60, 25)
;AM
$AMLabel = GUICtrlCreateLabel("AM", 248, 8, 36, 17)
$AM = GUICtrlCreateEdit("", 248, 25, 465, 130)
GUICtrlSetData(-1, "")
;PM
$PMLabel = GUICtrlCreateLabel("PM", 248, 158, 36, 17)
$PM = GUICtrlCreateEdit("", 248, 175, 465, 130)
GUICtrlSetData(-1, "")
;EVE
$EVELabel = GUICtrlCreateLabel("EVE", 248, 308, 36, 17)
$EVE = GUICtrlCreateEdit("", 248, 325, 465, 130)
GUICtrlSetData(-1, "")
;Family
$Familytab = GUICtrlCreateTab(248, 460, 475, 88)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Karen                                       ")
GUICtrlSetState(-1,$GUI_SHOW)
$Karennotes = GUICtrlCreateEdit("", 250, 485, 468, 60)
GUICtrlSetData(-1, "")
$TabSheet2 = GUICtrlCreateTabItem("Ash                                       ")
$Ashnotes = GUICtrlCreateEdit("", 250, 485, 468, 60)
GUICtrlSetData(-1, "")
$TabSheet3 = GUICtrlCreateTabItem("Josh                                     ")
$Joshnotes = GUICtrlCreateEdit("", 250, 485, 468, 60)
GUICtrlSetData(-1, "")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

        Case $savebutton
            FileWriteLine("Dairyfile.mdf", "" & GUICtrlRead($Dailynotes))
            FileWriteLine("Dairyfile.mdf", "" & GUICtrlRead($AM))
            FileWriteLine("Dairyfile.mdf", "" & GUICtrlRead($PM))
            FileWriteLine("Dairyfile.mdf", "" & GUICtrlRead($EVE))
            FileWriteLine("Dairyfile.mdf", "" & GUICtrlRead($Karennotes))
            FileWriteLine("Dairyfile.mdf", "" & GUICtrlRead($Ashnotes))
            FileWriteLine("Dairyfile.mdf", "" & GUICtrlRead($Joshnotes))
    EndSwitch
WEnd

Thanks in advance... and yeah it is personalised to my family atm...

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think your save code doesn't save all the nessicary information to allow for loading...

I'm guessing you want to mark the date and save/load based on which day is selected right?

Edited by evilertoaster

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

when saving you really need to keep all the data for that entry on one line.... like

FileWriteLine("Dairyfile.mdf",  GUICtrlRead($Dailynotes) &"|"& GUICtrlRead($AM)&"|"& "whatever" & "more info")

remebering to add a | between each entry....

so then you can

Case $loadbutton
_FileReadToArray(.... ect)

then search the array for what you want, day ect.... then stringsplit the array with the delimiter "|" and then display the results..

Edited by Aceguy

Share this post


Link to post
Share on other sites

ok, so i have this?

#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3> 
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>

; $'s and global's:
$File = FileRead(@ScriptDir & "Dairyfile.mdf")
$fileopen = FileOpen($File, 1)
$Fileclose = FileClose($File)

If FileExists("Dairyfile.mdf") then 
    Sleep(1000)
Else
    FileWrite("Dairyfile.mdf","")
EndIf

#Region ### START Koda GUI section ### Form=
$Calander = GUICreate("Calander", 724, 550)
$MonthCal1 = GUICtrlCreateMonthCal("", 8, 8, 231, 164)
$Progress1 = GUICtrlCreateProgress(8, 176, 230, 17)
;Daily notes
$DNLabel = GUICtrlCreateLabel("Daily notes", 8, 200, 233, 17)
$Dailynotes = GUICtrlCreateEdit("", 8, 220, 233, 280)
GUICtrlSetData(-1, "")
$savebutton = GUICtrlCreateButton("Save", 8, 505, 60, 25)
$loadbutton = GUICtrlCreateButton("Load", 70, 505, 60, 25)
;AM
$AMLabel = GUICtrlCreateLabel("AM", 248, 8, 36, 17)
$AM = GUICtrlCreateEdit("", 248, 25, 465, 130)
GUICtrlSetData(-1, "")
;PM
$PMLabel = GUICtrlCreateLabel("PM", 248, 158, 36, 17)
$PM = GUICtrlCreateEdit("", 248, 175, 465, 130)
GUICtrlSetData(-1, "")
;EVE
$EVELabel = GUICtrlCreateLabel("EVE", 248, 308, 36, 17)
$EVE = GUICtrlCreateEdit("", 248, 325, 465, 130)
GUICtrlSetData(-1, "")
;Family
$Familytab = GUICtrlCreateTab(248, 460, 475, 88)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Karen                                       ")
GUICtrlSetState(-1,$GUI_SHOW)
$Karennotes = GUICtrlCreateEdit("", 250, 485, 468, 60)
GUICtrlSetData(-1, "")
$TabSheet2 = GUICtrlCreateTabItem("Ash                                       ")
$Ashnotes = GUICtrlCreateEdit("", 250, 485, 468, 60)
GUICtrlSetData(-1, "")
$TabSheet3 = GUICtrlCreateTabItem("Josh                                     ")
$Joshnotes = GUICtrlCreateEdit("", 250, 485, 468, 60)
GUICtrlSetData(-1, "")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $loadbutton
            _FileReadToArray("Dairyfile.mdf", What goes here?)
        Case $savebutton
            FileWriteLine("Dairyfile.mdf", GUICtrlRead($Dailynotes) & "|" & GUICtrlRead($AM) & "|" & GUICtrlRead($PM) & "|" & GUICtrlRead($EVE) & "|" & GUICtrlRead($Karennotes) & "|" & GUICtrlRead($Ashnotes) & "|" & GUICtrlRead($Joshnotes) & "|")
    EndSwitch
WEnd

What goes in the load bit... and how do i get it to load dioffrent things on difffrent dates?

Share this post


Link to post
Share on other sites

Might want to look at the Ini* functions.

Might be a tad easier, if not, neater.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

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