Jump to content

Need help i think it is hard to write something like that


undead
 Share

Recommended Posts

Here I have to go get my kids from the in-laws, so I didn't have time to test it, but it should do what you want (I think :P)

#include <guiconstants.au3>

Dim $NewValues
$MainGui = GUICreate("Something", 200, 100)
$Combo = GUICtrlCreateCombo("", 50, 40, 120, 45)
$Filename = @DesktopDir & '\myini.ini'
$Section = 'mysection'
$Read = IniReadSection($Filename, $Section)
For $i = 1 To $Read[0][0]
    $NewValues = $NewValues & $Read[$i][1] & "|"
Next
GUICtrlSetData($Combo, StringTrimRight($NewValues, 1))

GUISetState()

While 1
    Sleep(100)
WEnd
It is ok but i have two problems :

ini file looks like that :

[variables]

16928 = asdasdaaaaaaaaaaaaaaaa

13020 = asdasdaaaaaaaaaaaaaaaa4

1725 = asdasdaaaaaaaaaaaaaaaa

15054 = asdasdaaaaaaaaaaaaaaaa

11299 = asdasdaaaaaaaaaaaaaaaa7

17205 = asdasdaaaaaaaaaaaaaaaaFiasdasdaaaaaaaaaaaaaaaawater

23471 = asdasdaaaaaaaaaaaaaaaa

17924 = asdasdaaaaaaaaaaaaaaaa2

13937 = asdasdaaaaaaaaaaaaaaaaImpact

13695 = asdasdaaaaaaaaaaaaaaaaact

13529 = asddddddddddd adsa ds adsa sad

20035 = asdasdaaaaaaaaaaaaaaaa

20030 = asfdadadadadasda

19936 = asdasdaaaaaaaaaaaaaaaact

15266 = asdasdaaaaaaaaaaaaaaaa6

..........etc over 19 000 lines ...

FIRST PROBLEM:

Dim $NewValues
    $Read = IniReadSection("myini.ini", "variables")
    For $i = 1 To $Read[0][0]
       $NewValues = $NewValues & $Read[$i][1] & "|"
    Next
     GUICtrlSetData($Combo, StringTrimRight($NewValues, 1))

IT add to combo from ini only ~1074 lines not all 19 000 lines

SECOND PROBLEM:

When user chose variable for egzample "asfdadadadadasda" from line "20030 = asfdadadadadasda "

i need to give back by button his KEY so "20030" how to do that ? i tried with iniread

case $msg = $button
    $sraczkacombo=Guictrlread($Combo)
    $ti = IniRead("myini.ini", "variables", "",$sraczkacombo )
    msgbox(64,"First generate weapon!","ID=" & $ti)

msgbox only for egzample for test :lmao: so it gives back selected value not his key ...

SO HOW TO READ KEY FROM VALUE ? and how to import all lines from ini file not only ~1074 ? i can send ini file and au3 file. Please Helpppppp

Edited by undead
Link to comment
Share on other sites

omg i know it is IniReadSection ... but i have problems with arrays ! :/

$var = IniReadSection("C:\Temp\myfile.ini", "section2")

If @error Then

MsgBox(4096, "", "Error occured, probably no INI file.")

Else

For $i = 1 To $var[0][0]

MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])

Next

EndIf

and i know help file too :P but need to

GuiCombo that have list of all values ! and recive to user by button that i will create KEY for that value that he chosed

...

u posted me a link with many posts i am weak at english :/

Link to comment
Share on other sites

  • Moderators

Here I have to go get my kids from the in-laws, so I didn't have time to test it, but it should do what you want (I think :P)

#include <guiconstants.au3>

Dim $NewValues
$MainGui = GUICreate("Something", 200, 100)
$Combo = GUICtrlCreateCombo("", 50, 40, 120, 45)
$Filename = @DesktopDir & '\myini.ini'
$Section = 'mysection'
$Read = IniReadSection($Filename, $Section)
For $i = 1 To $Read[0][0]
    $NewValues = $NewValues & $Read[$i][1] & "|"
Next
GUICtrlSetData($Combo, StringTrimRight($NewValues, 1))

GUISetState()

While 1
    Sleep(100)
WEnd

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Here I have to go get my kids from the in-laws, so I didn't have time to test it, but it should do what you want (I think :P)

#include <guiconstants.au3>

Dim $NewValues
$MainGui = GUICreate("Something", 200, 100)
$Combo = GUICtrlCreateCombo("", 50, 40, 120, 45)
$Filename = @DesktopDir & '\myini.ini'
$Section = 'mysection'
$Read = IniReadSection($Filename, $Section)
For $i = 1 To $Read[0][0]
    $NewValues = $NewValues & $Read[$i][1] & "|"
Next
GUICtrlSetData($Combo, StringTrimRight($NewValues, 1))

GUISetState()

While 1
    Sleep(100)
WEnd
It is ok but i have two problems :

ini file looks like that :

[variables]

16928 = asdasdaaaaaaaaaaaaaaaa

13020 = asdasdaaaaaaaaaaaaaaaa4

1725 = asdasdaaaaaaaaaaaaaaaa

15054 = asdasdaaaaaaaaaaaaaaaa

11299 = asdasdaaaaaaaaaaaaaaaa7

17205 = asdasdaaaaaaaaaaaaaaaaFiasdasdaaaaaaaaaaaaaaaawater

23471 = asdasdaaaaaaaaaaaaaaaa

17924 = asdasdaaaaaaaaaaaaaaaa2

13937 = asdasdaaaaaaaaaaaaaaaaImpact

13695 = asdasdaaaaaaaaaaaaaaaaact

13529 = asddddddddddd adsa ds adsa sad

20035 = asdasdaaaaaaaaaaaaaaaa

20030 = asfdadadadadasda

19936 = asdasdaaaaaaaaaaaaaaaact

15266 = asdasdaaaaaaaaaaaaaaaa6

..........etc over 19 000 lines ...

FIRST PROBLEM:

Dim $NewValues
    $Read = IniReadSection("myini.ini", "variables")
    For $i = 1 To $Read[0][0]
       $NewValues = $NewValues & $Read[$i][1] & "|"
    Next
     GUICtrlSetData($Combo, StringTrimRight($NewValues, 1))

IT add to combo from ini only ~1074 lines not all 19 000 lines

SECOND PROBLEM:

When user chose variable for egzample "asfdadadadadasda" from line "20030 = asfdadadadadasda "

i need to give back by button his KEY so "20030" how to do that ? i tried with iniread

case $msg = $button
    $sraczkacombo=Guictrlread($Combo)
    $ti = IniRead("myini.ini", "variables", "",$sraczkacombo )
    msgbox(64,"First generate weapon!","ID=" & $ti)

msgbox only for egzample for test :lmao: so it gives back selected value not his key ...

SO HOW TO READ KEY FROM VALUE ? and how to import all lines from ini file not only ~1074 ? i can send ini file and au3 file. Please Helpppppp

Link to comment
Share on other sites

  • Moderators

I'm reading this, and wondering if you know that your ini file cannot be more than 64 kb's. And I would think that 19,000 lines would be much more than that?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I'm reading this, and wondering if you know that your ini file cannot be more than 64 kb's. And I would think that 19,000 lines would be much more than that?

I DIDNT KNOW THAT !!!! that change everything ... maybe i will change that ini or separate it hmm

but how to recive key from value is that possible with ini commands ?

Link to comment
Share on other sites

  • Moderators

If you set up a "File" like you set up your "Ini" withouth using [sections], and only using 'Key' type information, this may help.

#include <guiconstants.au3>
#include <file.au3>
Dim $Filetoread = "Put File Path and Name here"
Dim $Array
Dim $NewList

$MainGui = GUICreate("Something", 200, 100)
$Combo = GUICtrlCreateCombo("", 50, 40, 120, 45)
_FileReadToArray($Filetoread, $Array)
For $x = 1 To UBound($Array) - 1
    $Split = StringSplit(StringStripWS($Array[$x], 7), '=')
    If IsArray($Split) Then 
        $NewList = $NewList & $Split[2] & '|'
    EndIf
Next
GUICtrlSetData($Combo, StringTrimRight($NewList, 1))

GUISetState()

While 1
    Sleep(100)
WEnd

Edit:

If you are ending up with a space at the begining of your string using what I gave you, change this:

GUICtrlSetData($Combo, StringTrimRight($NewList, 1))

To:

GUICtrlSetData($Combo, StringTrimRight(StringTrimLeft($NewList, 1), 1))

Edit2:

I took this '$x = $x + 1' out because I had changed the script to only accept Split[2] and forgot to edit that.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

If you set up a "File" like you set up your "Ini" withouth using [sections], and only using 'Key' type information, this may help.

#include <guiconstants.au3>
#include <file.au3>
Dim $Filetoread = "Put File Path and Name here"
Dim $Array
Dim $NewList

$MainGui = GUICreate("Something", 200, 100)
$Combo = GUICtrlCreateCombo("", 50, 40, 120, 45)
_FileReadToArray($Filetoread, $Array)
For $x = 1 To UBound($Array) - 1
    $Split = StringSplit(StringStripWS($Array[$x], 7), '=')
    If IsArray($Split) Then 
        $NewList = $NewList & $Split[2] & '|'
    EndIf
Next
GUICtrlSetData($Combo, StringTrimRight($NewList, 1))

GUISetState()

While 1
    Sleep(100)
WEnd

Edit:

If you are ending up with a space at the begining of your string using what I gave you, change this:

GUICtrlSetData($Combo, StringTrimRight($NewList, 1))

To:

GUICtrlSetData($Combo, StringTrimRight(StringTrimLeft($NewList, 1), 1))

Edit2:

I took this '$x = $x + 1' out because I had changed the script to only accept Split[2] and forgot to edit that.

thanks man works good only one think

can it not show first [space] after "=" ?

check with that ini

16928   =     Armor Shatter  
13020   =     Death Touch  Blast WaveRank 4  
1725    =     Death Touch  Distract  
15054   =     Death Touch  Distract Test  
11299   =     Death Touch  EviscerateRank 7  
17205   =     Death Touch  Winterfall Firewater
17924   =     Ice shards pelt the target area doing o1 Frost damage over d  Soul FireRank 2  
13937   =     Lesser Invisibility  Enchant 2H Weapon - Greater Impact  
13695   =     Lesser Invisibility  Enchant 2H Weapon - Impact  
13529   =     Lesser Invisibility  Enchant 2H Weapon - Lesser Impact  
20035   =     Lesser Invisibility  Enchant 2H Weapon - Major Spirit  
20030   =     Lesser Invisibility  Enchant 2H Weapon - Superior Impact  
19936   =     Lesser Invisibility  zzOLDTest Enchant 2H Weapon - Greater Impact

it shows []variable.

Andsecond question :

when somene choose him variable from combo then click button and key from that value is show on guictrlcreateedit :P on the right

SO WHEN user choose

Lesser Invisibility zzOLDTest Enchant 2H Weapon - Greater Impact

AND CLICK BUTTON

then on the right u will se

19936

Link to comment
Share on other sites

it is stupid :P i changed ini just delleted all spaces before and after = sign

so problem with spaces solved i need only now know how to recive key from selected value by a User of program.

Edited by undead
Link to comment
Share on other sites

it is stupid :P i changed ini just delleted all spaces before and after = sign

so problem with spaces solved i need only now know how to recive key from selected value by a User of program.

- For stripping spaces you can also use StringStripWS

- for receive key by value do this:

After StringSplit ( = ) remember both key and value (in 2dimensional array or in 2 arrays - keys and values)

In code where you have value, find index of this value in array and from this index read also key

(in second dimension or in second array)

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