Jump to content
Sign in to follow this  
mini

HELP How to reaload "value" to a "input box" from a ini file!?

Recommended Posts

mini
Fire

Witout help file this would be hard to understand.

I think you need check help file firstly and read all about.

Secondly,This is a basic script.It can do what you are asking.

I comment all necessary "notes" in it.So check help file for it for understand what it does.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
Dim $avarray

For $i=0 To 100
    FileWrite(@ScriptDir&"\newcreated.ini",$i & @CRLF)  ;creating ini file from 0 to 100 values
Next
_FileReadToArray(@ScriptDir&"\newcreated.ini",$avarray) ;getting content of file to $avarray
FileDelete(@ScriptDir&"\newcreated.ini") ;deleting existing and new created ini file


#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("Form1", 470, 141, 192, 124)
$Input1 = GUICtrlCreateInput("", 88, 24, 281, 21)
;For $i=0 To $avarray[0]
GUICtrlSetData($Input1,$avarray[89])    ;guictrlsetdata() this will set $avarray[89] to $input
;Next
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd
Edited by Sh3llC043r

[size="5"] [/size]

Share this post


Link to post
Share on other sites
mini

Witout help file this would be hard to understand.

I think you need check help file firstly and read all about.

Secondly,This is a basic script.It can do what you are asking.

I comment all necessary "notes" in it.So check help file for it for understand what it does.

Thx for your replay, but i dont understand where ill put your code on my Gui.

My Gui is like this at the moment...

#cs ----------------------------------------------------------------------------

  Author:         rAsOOl

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


#Region ### START Koda GUI section ### Form=
Dim $Version = "1"
Dim $Start = 0

;Main.
$GUI = GUICreate("Base de Contactos BES V1", 633, 454)

;Back Ground
$pic = GuiCtrlCreatePic(@ScriptDir & "\BES" & "\BES.jpg" ,0,0,633,454)
GUICtrlSetState(-1,$GUI_DISABLE)

;Buttons
$Procura = GUICtrlCreateButton("Procura", 152, 16, 75, 25)
$Novo_Registo = GUICtrlCreateButton("Novo_Registo", 152, 56, 75, 25)
$Depositos = GUICtrlCreateButton("Depositos", 144, 168, 75, 25)
$Gravar = GUICtrlCreateButton("Gravar", 144, 198, 75, 25)
$Clear = GUICtrlCreateButton("Clear", 544, 16, 75, 25)

;Input
$InputN_Adesao = GUICtrlCreateInput("N_Adesao", 16, 16, 121, 21)
$InputNome = GUICtrlCreateInput("Nome", 312, 32, 121, 21)
$InputContacto = GUICtrlCreateInput("Contacto", 320, 64, 121, 21)
$InputEmail = GUICtrlCreateInput("Email", 312, 104, 121, 21)

;Label
$LabelNome = GUICtrlCreateLabel("Nome", 272, 24, 32, 17)
$LabelContacto = GUICtrlCreateLabel("Contacto", 264, 64, 47, 17)
$LabelEMail = GUICtrlCreateLabel("EMail", 272, 96, 30, 17)

;Groups
$Group1 = GUICtrlCreateGroup("Group1", 248, 8, 241, 161)

GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3
            _Check4CLOSEClicked()
        Case $Gravar
            _Check4Gravar() 
        Case $Clear
            _Check4Clear()  
        Case $Procura
            _Check4Procura()
    EndSwitch
WEnd

Func _Check4CLOSEClicked();Exit
$answer = MsgBox(36, "Wanning", "Are you sure?", 8 )
If $answer = 6 Then
    Exit
EndIf   
EndFunc

Func _Check4Procura()
; IniRead ( "Base de Contactos BES.ini", "Nome")
IniRead ( "Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Nome" ,  GuiCtrlSetData($inputName) )
;GuiCtrlSetData ($InputN_Adesao, "")
; GuiCtrlSetData ($InputNome, "")
 ;GuiCtrlSetData ($InputContacto, "")
 ;GuiCtrlSetData ($InputEmail, "")
EndFunc

Func _Check4Clear()
 ;GuiCtrlSetData ($InputN_Adesao, "")
 GuiCtrlSetData ($InputNome, "")
 GuiCtrlSetData ($InputContacto, "")
 GuiCtrlSetData ($InputEmail, "")
EndFunc

Func _Check4Gravar()
    IniWrite ( "Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Nome" , GUICtrlRead($InputNome))
    IniWrite ( "Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Contacto" , GUICtrlRead($InputContacto))
    IniWrite ( "Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Email" , GUICtrlRead($InputEmail))
    
EndFunc

The "PROCURA" Button is the Shearch button.

sow how do i use your code!?

Edited by mini

Share this post


Link to post
Share on other sites
Fulano

Disclaimer: All of these examples are dry coded, so errors are probably hiding in here somewhere

I am assuming that this is a continuation of your question here. I have no clue how you are storing your date, but here goes anyhow.

For the purpose of this I am going to assume you are storing the data with this:

IniWrite ( "Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Nome" , GUICtrlRead($InputNome))
IniWrite ( "Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Contacto" , GUICtrlRead($InputContacto))
IniWrite ( "Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Email" , GUICtrlRead($InputEmail))

To read this back you would do something like this:

GUICtrlSetData ($InputNome, IniRead ("Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Nome"))
GUICtrlSetData ($InputContacto, IniRead ("Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Contacto"))
GUICtrlSetData ($InputEmail, IniRead ("Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Email"))

Note that this does not save the data to any variable, it only updates the Control, so you'd have to read the control again to get the data back.

Boa Sorte

Fulano


#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites
mini

Disclaimer: All of these examples are dry coded, so errors are probably hiding in here somewhere

I am assuming that this is a continuation of your question here. I have no clue how you are storing your date, but here goes anyhow.

For the purpose of this I am going to assume you are storing the data with this:

IniWrite ( "Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Nome" , GUICtrlRead($InputNome))
IniWrite ( "Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Contacto" , GUICtrlRead($InputContacto))
IniWrite ( "Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Email" , GUICtrlRead($InputEmail))

To read this back you would do something like this:

GUICtrlSetData ($InputNome, IniRead ("Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Nome"))
GUICtrlSetData ($InputContacto, IniRead ("Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Contacto"))
GUICtrlSetData ($InputEmail, IniRead ("Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Email"))

Note that this does not save the data to any variable, it only updates the Control, so you'd have to read the control again to get the data back.

Boa Sorte

Fulano

Well i try wht you did, but it give me a error:

GUICtrlSetData ($InputNome, IniRead ("Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Nome"))

GUICtrlSetData ($InputNome, ^ ERROR

Edited by mini

Share this post


Link to post
Share on other sites
Fulano

De nada, a ajuda que eu recebi, passo pra ti.


#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites
mini

De nada, a ajuda que eu recebi, passo pra ti.

Well i try wht you did, but it give me a error:

GUICtrlSetData ($InputNome, IniRead ("Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Nome"))

GUICtrlSetData ($InputNome, ^ ERROR

i got this error bro, can you help me on this?!?

Share this post


Link to post
Share on other sites
Fulano
Esqueci de fornecer um valor de default
GUICtrlSetData ($InputNome, IniRead ("Base de Contactos BES.ini", GUICtrlRead($InputN_Adesao) , "Nome", "Informação não encontrada"))

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites
mini

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.