Jump to content

iniread for pros.......


Recommended Posts

so guy i made this programm:

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        Artus Krieger <Artus.Krieger@gmx.de>
;
; Script Function:
;   Template AutoIt script.
;
; ----------------------------------------------------------------------------


#include <GuiConstants.au3>




func start()
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("MyGUI", 459, 352,(@DesktopWidth-459)/2, (@DesktopHeight-352)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$alleFarmen = GuiCtrlCreateTreeview(0, 0, 220, 140)
$neu = GuiCtrlCreateButton("Neu", 0, 140, 220, 20)
$bearbeiten = GuiCtrlCreateButton("Bearbeiten", 0, 160, 220, 20)
$loeschen = GuiCtrlCreateButton("Löschen", 0, 180, 220, 20)
$label_6 = GuiCtrlCreateLabel("Punkte", 220, 10, 240, 20)
$label_7 = GuiCtrlCreateLabel("Planeten ", 220, 40, 240, 20)
$label_8 = GuiCtrlCreateLabel("Koords", 220, 70, 240, 130)
$label_9 = GuiCtrlCreateGroup("Schiffe", 0, 200, 220, 140)
$Label_10 = GuiCtrlCreateLabel("SpioSonden", 10, 220, 200, 20)
$Label_11 = GuiCtrlCreateLabel("Tjuger", 10, 250, 200, 20)
$Label_12 = GuiCtrlCreateLabel("Cougar", 10, 280, 200, 20)
$Label_13 = GuiCtrlCreateLabel("LeV", 10, 310, 200, 20)
$Group_14 = GuiCtrlCreateGroup("Flotte des Planeten", 230, 200, 220, 140)
$Label_15 = GuiCtrlCreateLabel("SpioSonden", 240, 220, 210, 20)
$Label_16 = GuiCtrlCreateLabel("Tjuger", 240, 250, 210, 20)
$Label_17 = GuiCtrlCreateLabel("Cougar", 240, 280, 210, 20)
$Label_18 = GuiCtrlCreateLabel("LeV", 240, 310, 210, 20)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $neu
        neu()
    ;;;
    EndSelect
WEnd
endfunc

func neu()
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("Neue Farm speichern", 361, 574,(@DesktopWidth-361)/2, (@DesktopHeight-574)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Label_1 = GuiCtrlCreateLabel("Name", 10, 10, 90, 20)
$Name = GuiCtrlCreateInput("", 110, 10, 110, 20)
$Label_3 = GuiCtrlCreateLabel("Punkte:", 10, 40, 90, 20)
$punkte = GuiCtrlCreateInput("", 110, 40, 110, 20)
$Label_5 = GuiCtrlCreateLabel("Planetenanzahl:", 10, 70, 90, 20)
$planis = GuiCtrlCreateInput("", 110, 70, 110, 20)
$Label_7 = GuiCtrlCreateLabel("Planet1:", 20, 120, 60, 20)
$Group_8 = GuiCtrlCreateGroup("Koords", 20, 100, 330, 310)
$Label_9 = GuiCtrlCreateLabel("Planet2:", 20, 150, 60, 20)
$Label_10 = GuiCtrlCreateLabel("Planet3:", 20, 180, 60, 20)
$Label_11 = GuiCtrlCreateLabel("Planet4:", 20, 210, 50, 20)
$Label_12 = GuiCtrlCreateLabel("Planet5:", 20, 240, 50, 20)
$Label_13 = GuiCtrlCreateLabel("Planet6:", 20, 270, 50, 20)
$Label_14 = GuiCtrlCreateLabel("Planet7:", 20, 300, 50, 20)
$Label_15 = GuiCtrlCreateLabel("Planet8:", 20, 330, 50, 20)
$Label_16 = GuiCtrlCreateLabel("Planet9:", 20, 360, 40, 20)
$Label_17 = GuiCtrlCreateLabel("Planet10:", 20, 390, 50, 20)
$k1 = GuiCtrlCreateInput("", 90, 110, 90, 20)
$k2 = GuiCtrlCreateInput("", 90, 140, 90, 20)
$k3 = GuiCtrlCreateInput("", 90, 170, 90, 20)
$k4 = GuiCtrlCreateInput("", 90, 200, 90, 20)
$k5 = GuiCtrlCreateInput("", 90, 230, 90, 20)
$k6 = GuiCtrlCreateInput("", 90, 260, 90, 20)
$k7 = GuiCtrlCreateInput("", 90, 290, 90, 20)
$k8 = GuiCtrlCreateInput("", 90, 320, 90, 20)
$k9 = GuiCtrlCreateInput("", 90, 350, 90, 20)
$k10 = GuiCtrlCreateInput("", 90, 380, 90, 20)
$Label_28 = GuiCtrlCreateLabel("Planet11:", 190, 120, 50, 20)
$Label_29 = GuiCtrlCreateLabel("Planet12:", 190, 150, 50, 20)
$Label_30 = GuiCtrlCreateLabel("Planet13:", 190, 180, 60, 20)
$Label_31 = GuiCtrlCreateLabel("Planet14:", 190, 210, 60, 20)
$Label_32 = GuiCtrlCreateLabel("Planet15", 190, 240, 60, 20)
$Label_33 = GuiCtrlCreateLabel("Planet16:", 190, 270, 60, 20)
$Label_34 = GuiCtrlCreateLabel("Planet17:", 190, 300, 60, 20)
$Label_35 = GuiCtrlCreateLabel("Planet18:", 190, 330, 60, 20)
$Label_36 = GuiCtrlCreateLabel("Planet19:", 190, 360, 60, 20)
$Label_37 = GuiCtrlCreateLabel("Planet20:", 190, 390, 60, 20)
$k11 = GuiCtrlCreateInput("", 250, 110, 90, 20)
$k12 = GuiCtrlCreateInput("", 250, 140, 90, 20)
$k13 = GuiCtrlCreateInput("", 250, 170, 90, 20)
$k14 = GuiCtrlCreateInput("", 250, 200, 90, 20)
$k15 = GuiCtrlCreateInput("", 250, 230, 90, 20)
$k16 = GuiCtrlCreateInput("", 250, 260, 90, 20)
$k17 = GuiCtrlCreateInput("", 250, 290, 90, 20)
$k18 = GuiCtrlCreateInput("", 250, 320, 90, 20)
$k19 = GuiCtrlCreateInput("", 250, 350, 90, 20)
$k20 = GuiCtrlCreateInput("", 250, 380, 90, 20)
$Group_48 = GuiCtrlCreateGroup("Flotte", 20, 420, 330, 90)
$Label_49 = GuiCtrlCreateLabel("SpioSonden", 30, 440, 70, 20)
$sonden = GuiCtrlCreateInput("", 110, 440, 70, 20)
$Label_51 = GuiCtrlCreateLabel("Tjuger", 210, 440, 50, 20)
$tjuger = GuiCtrlCreateInput("", 270, 440, 70, 20)
$Label_53 = GuiCtrlCreateLabel("Cougar", 30, 480, 60, 20)
$cougar = GuiCtrlCreateInput("", 110, 470, 70, 20)
$Label_55 = GuiCtrlCreateLabel("LeV", 210, 470, 30, 20)
$lev = GuiCtrlCreateInput("", 270, 470, 70, 20)
$Speichern = GuiCtrlCreateButton("OK", 200, 530, 140, 30)
$Back = GuiCtrlCreateButton("<---Zurück", 20, 530, 140, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Speichern
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "Punkte", "" & GUICtrlRead($punkte))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "Planeten", "" &GUICtrlRead($planis))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k1", "" & GUICtrlRead($k1))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k2", "" & GUICtrlRead($k2))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k3", "" & GUICtrlRead($k3))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k4", "" & GUICtrlRead($k4))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k5", "" & GUICtrlRead($k5))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k6", "" & GUICtrlRead($k6))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k7", "" & GUICtrlRead($k7))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k8", "" & GUICtrlRead($k8))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k9", "" & GUICtrlRead($k9))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k10", "" & GUICtrlRead($k10))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k11", "" & GUICtrlRead($k11))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k12", "" & GUICtrlRead($k12))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k13", "" & GUICtrlRead($k13))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k14", "" & GUICtrlRead($k14))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k15", "" & GUICtrlRead($k15))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k16", "" & GUICtrlRead($k16))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k17", "" & GUICtrlRead($k17))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k18", "" & GUICtrlRead($k18))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k19", "" & GUICtrlRead($k19))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "k20", "" & GUICtrlRead($k20))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "Spios", ""  & GUICtrlRead($sonden))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "Tjuger", "" & GUICtrlRead($tjuger))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "Cougar", "" & GUICtrlRead($cougar))
        IniWrite("Farmen.ini", "" & GUICtrlRead($name), "LeV", "" & GUICtrlRead($lev))
        msgbox(0, "" & GUICtrlRead($name) & "", "Der Spieler " & GUICtrlRead($name) & " wurde erfolgreich zu ihrer Liste hinzugefügt!" & @lf & "Viel Spaß beim Farmen!")
    EndSelect
WEnd
Exit
EndFunc


start()


Exit

______________________________________________________

it works fine but i have one problem^^

i want to show the names that are saved in farmen.ini int the brackets (---->[] <----)

in treeview ($alleFarmen)

has any1 an idea how to realize it??

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Link to comment
Share on other sites

i want to show the names that are saved in farmen.ini int the brackets (---->[] <----)

in treeview ($alleFarmen)

has any1 an idea how to realize it??

<{POST_SNAPBACK}>

$text = "[" & IniRead($file,"section","key","default") & "]"

then use the value of $text in your GUICtrl*

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

but the ini is looking like this:

[Da_Killa]
Punkte=5000
Planeten=20
k1=11:11:11
k2=12:12:12
k3=13
k4=14
k5=15
k6=16
k7=17
k8=18
k9=19
k10=20
k11=23
k12=24
k13=25
k14=26
k15=27
k16=28
k17=29
k18=30
k19=31
k20=32
Spios=999
Tjuger=99999
Cougar=9999
LeV=999999
[Test]
Punkte=tttt
Planeten=zzzz
k1=ggh
k2=j
k3=gf
k4=kjg
k5=kogl
k6=i
k7=gj
k8=hg
k9=gjkioug
k10=ggjkgjk
k11=gjkgkhkj
k12=löjk
k13=ölk
k14=lö
k15=kö
k16=klh
k17=iuh
k18=ig
k19=jkg
k20=zfr
Spios=hjgh
Tjuger=iut
Cougar=uf
LeV=juh

this: [Da_Killa] and this: [Test] should be shown in the treeview^^

but the ini could also have 300 of different names ([da_killa]) and all should be shown in the treeview...

is there a way?

and if i klick in one of them the values like LeVs and so should be loaded^^

but thx for the fast answer

Edited by Analritter

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Link to comment
Share on other sites

this: [Da_Killa] and this: [Test] should be shown in the treeview^^

but the ini could also have 300 of different names ([da_killa]) and all should be shown in the treeview...

is there a way?

and if i klick in one of them the values like LeVs and so should be loaded^^

but thx for the fast answer

<{POST_SNAPBACK}>

Look into the IniReadSectionNames("filename") function.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

now i've got the next problem^^

ive made this:

func start()
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("RIP Alte Runde .:|U are all in memory!|:.", 459, 352,(@DesktopWidth-459)/2, (@DesktopHeight-352)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$alleFarmen = GUICtrlCreateTreeView("Farmen",0, 0, 140, 130)
$farmliste = GUICtrlCreateTreeViewItem("Farmen", $allefarmen)
$inilesen = IniReadSectionNames("Farmen.ini")
If @error Then 
    MsgBox(4096, "Fehler", "Ein Feler ist aufgetreten!" & @crlf &"Wahrscheinlich existiert die Farmen.ini nicht! Falls sie doch existieren sollte melde diesen Fehler bitte Da_Killa" )
Else
    For $i = 1 To $inilesen[0]
        $test = GuiCtrlCreateTreeViewItem(""& $inilesen[$i], $farmliste)
    Next
EndIf
$neu = GuiCtrlCreateButton("Neu", 0, 140, 220, 20)
$bearbeiten = GuiCtrlCreateButton("Bearbeiten", 0, 160, 220, 20)
$loeschen = GuiCtrlCreateButton("Löschen", 0, 180, 220, 20)
$label_6 = GuiCtrlCreateLabel("Punkte", 220, 10, 240, 20)
$label_7 = GuiCtrlCreateLabel("Planeten ", 220, 40, 240, 20)
$label_8 = GuiCtrlCreateLabel("Koords", 220, 70, 240, 130)
$label_9 = GuiCtrlCreateGroup("Schiffe", 0, 200, 220, 140)
$Label_10 = GuiCtrlCreateLabel("SpioSonden", 10, 220, 200, 20)
$Label_11 = GuiCtrlCreateLabel("Tjuger", 10, 250, 200, 20)
$Label_12 = GuiCtrlCreateLabel("Cougar", 10, 280, 200, 20)
$Label_13 = GuiCtrlCreateLabel("LeV", 10, 310, 200, 20)
$Group_14 = GuiCtrlCreateGroup("Flotte des Planeten", 230, 200, 220, 140)
$Label_15 = GuiCtrlCreateLabel("SpioSonden", 240, 220, 210, 20)
$Label_16 = GuiCtrlCreateLabel("Tjuger", 240, 250, 210, 20)
$Label_17 = GuiCtrlCreateLabel("Cougar", 240, 280, 210, 20)
$Label_18 = GuiCtrlCreateLabel("LeV", 240, 310, 210, 20)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $neu
        neu()
    Case $msg = $bearbeiten
        msgbox(0, "", "" & GUICtrlRead($test)& "")
    ;;;
    EndSelect
WEnd
endfunc

i want to get the text in the treeview to be shown in the msgbox....

has anyone got an idea??

i tried :

msgbox(0, "", "" & GUICtrlRead($test)& "")

and

msgbox(0, "", "" & $test & "")

:)

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Link to comment
Share on other sites

now  i've got the next problem^^

ive made this:

<snip>

<snip>
$inilesen = IniReadSectionNames("Farmen.ini")
If @error Then 
    MsgBox(4096, "Fehler", "Ein Feler ist aufgetreten!" & @crlf &"Wahrscheinlich existiert die Farmen.ini nicht! Falls sie doch existieren sollte melde diesen Fehler bitte Da_Killa" )
Else
    For $i = 1 To $inilesen[0]
        $test = GuiCtrlCreateTreeViewItem(""& $inilesen[$i], $farmliste)
    Next
EndIf
<snip>

<snip>

ok, when you're reading the data from the array $inilesen you're putting it into a non-array variable...so the contents of the $test variable will ALWAYS be the contents of the last container of the array.

You need to read

i tried :

msgbox(0, "", "" & GUICtrlRead($test)& "")

msgbox(0, "", "" & $test & "")
as:

msgbox(0,"","" & GUICtrlRead($inilesen[$x]))

msgbox(0, "", "" & $inilesen[$x])

To get this value, could you do a GUICtrlRead() on the ListView when the user clicks it?

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

ok i declared $x as 1 but if i use it like this:

msgbox(0,"","" & GUICtrlRead($inilesen[$x]))

it only receives 0

if i use this:

msgbox(0, "", "" & $inilesen[$x])
it receives only the first entry^^

can anyone solve this problem?

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

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...