Sign in to follow this  
Followers 0
MrSergey

Update data in the list problem

2 posts in this topic

Hello, I am sorry for my English.

I write the program, but I had a problem with update data in the list.

I have table names and IPs. I write data to ini file. If i click to name in list the IP automatic change.

Problem: if i add new name and IP in list the IP do not change if i click to name in list, but if i delete name from list all works as is necessary.

my code:

#include <GUIConstants.au3>

#include <WindowsConstants.au3>

#include <ButtonConstants.au3>

#include <ComboConstants.au3>

#include <GUIConstantsEx.au3>

#include <EditConstants.au3>

#include <StaticConstants.au3>

Dim $name[50]

Dim $ip[50]

Global $kolvozp

$namezp = ""

$i = 0

$oldspysok = ""

$numb = 0

GUICreate("My Program",600,300)

filereadzp()

$spysok = GUICtrlCreateList("", 10, 30, 260, 230)

GUICtrlSetData(-1,$namezp,$name[1])

$spysok1 = $name[1]

For $i = 1 to $kolvozp

If $spysok1 = $name[$i] Then

ExitLoop

EndIf

Next

GUICtrlCreateLabel ("IP :", 280, 32)

$ip1 = GUICtrlCreateInput ($ip[$i], 410, 30,180)

$n1 = GUICtrlCreateButton("Add", 10, 270, 80,20)

$n2 = GUICtrlCreateButton("Delete", 100, 270, 80,20)

$n3 = GUICtrlCreateButton("Apply", 190, 270, 80,20)

GUISetState ()

Do

$msg = GUIGetMsg()

If $msg = $spysok And GUICtrlRead($spysok) <> $oldspysok Then

For $i = 1 to $kolvozp

If GUICtrlRead($spysok) = $name[$i] Then

;~ MsgBox(0,"",$k&" "&$i)

GUICtrlSetData($ip1,$ip[$i])

;~ MsgBox(0,"",$ip[$i]&" "&GUICtrlRead($ip1))

ExitLoop

EndIf

Next

$oldspysok = GUICtrlRead($spysok)

EndIf

If $msg = $n3 Then

If $i < 1 And $i > $kolvozp Then

$i = 1

EndIf

FileWritezp($i)

filereadzp()

EndIf

If $msg = $n1 Then

add()

filereadzp()

GUICtrlSetData($spysok,"")

GUICtrlSetData($spysok,$namezp,$name[$i])

EndIf

If $msg = $n2 Then

del($i)

filereadzp()

GUICtrlSetData($spysok,"")

GUICtrlSetData($spysok,$namezp,$name[$i])

EndIf

Sleep(5)

Until $msg = $GUI_EVENT_CLOSE

Func filereadzp()

$namezp = ""

$zp = IniReadSection("set.ini", "mes")

$kolvozp = (UBound($zp) - 1)/2

If $kolvozp < 1 Then

$kolvozp = 1

EndIf

For $t = 1 to $kolvozp

$name[$t] = IniRead ("Set.ini", "mes", "name"&$t, "2")

If $t <> $kolvozp Then

$namezp = $namezp & $name[$t]&"|"

Else

$namezp = $namezp & $name[$t]

EndIf

$ip[$t] = IniRead ("Set.ini", "mes", "ip"&$t, "2")

Next

EndFunc

Func FileWritezp($i)

IniWrite ("Set.ini", "mes", "name"&$i, $name[$i])

IniWrite ("Set.ini", "mes", "ip"&$i, GUICtrlRead($ip1))

EndFunc

Func add()

GUICreate("Add",350,205)

GUICtrlCreateLabel ("Name:", 10, 7)

$names = GUICtrlCreateInput ("", 160, 5,180)

GUICtrlCreateLabel ("IP :", 10, 32)

$ips = GUICtrlCreateInput ("", 160, 30,180)

$n4 = GUICtrlCreateButton("Add", 50, 170, 80,25)

$n5 = GUICtrlCreateButton("Cancel", 210, 170, 80,25)

GUISetState()

Do

$msg1 = GUIGetMsg()

If $msg1 = $n4 Then

$name[$kolvozp+1] = $names

$ip1 = $ips

$name[$kolvozp+1] = GUICtrlRead($name[$kolvozp+1])

If $ip[$kolvozp] <> "2"Then

$i = $kolvozp+1

Else

$i = $kolvozp

$name[$kolvozp] =$name[$kolvozp+1]

EndIf

FileWritezp($i)

ExitLoop

EndIf

If $msg1 = $n5 Then

ExitLoop

EndIf

Until $msg1 = $GUI_EVENT_CLOSE

GUIDelete()

EndFunc

Func del($i)

For $t = $i to $kolvozp-1

$name[$t] = $name[$t+1]

$ip[$t] = $ip[$t+1]

IniWrite ("Set.ini", "mes", "name"&$t, $name[$t])

IniWrite ("Set.ini", "mes", "ip"&$t, $ip[$t])

Next

IniDelete ("Set.ini", "mes", "name"&$t)

IniDelete ("Set.ini", "mes", "ip"&$t)

EndFunc

Share this post


Link to post
Share on other sites



Help me pls

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