Sign in to follow this  
Followers 0
Agent29

Saving and Loading Data

2 posts in this topic

Hello!

Ok, I have the following program

Posted Image

Next to the "Warning" Button, I would like to add a Drop down, This I can do. But I want it to auto populate by reading data from a INI File, and When you select one, It fills the input boxes with the Information under that section in the INI file...

INI file like this

[Pokename]
HP=
ATK=
DEF=
SPATK=
SPDEF=
SPD=

Any Idea to better it are welcome :D Please point me in the right direction here.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

u can use like this:

;files
Global Const $inifile=@ScriptDir & "\setings.ini"
;default proces
$atk=10
$def=2
$hp=100

Func CreateorReadini()
    if not FileExists($inifile) Then
    $inifileopen = FileOpen($inifile, 1)
        If $inifileopen = -1 Then
        MsgBox(0, "Error", "Unable to open ini file.")
            Exit
        EndIf
    FileClose($inifileopen)
    
    readvaluesfromini()
    IniWrite($inifile,"Settings", "Attack", $atk)
    IniWrite($inifile,"Settings", "HP", $hp)
    IniWrite($inifile,"Settings", "Defence", $def)
    endIf
EndFunc

func readvaluesfromini()
    if FileExists($inifile) Then
        Global $atk = IniRead($inifile, "Settings", "Attack", 0 )
        Global $hp = IniRead($inifile, "Settings", "HP", 0 )
        Global $def = IniRead($inifile, "Settings", "Defence", 0)
    EndIf
EndFunc
Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/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