Jump to content

Combo gives same value everytime.


WackOo
 Share

Recommended Posts

Hello Everybody, I'm new and not to advanced in AutoIt but I'm trying to create a Sync Tool for a game I'm playing.

I'm using a combo box to select the save game, unfortunately it always returns value "4", what am i doing wrong?..

Do i need to unset the value or what is it that i'm missing.

I'd also like some advice, cause for this savegame i will need to read a xml file, is there anything XML like for AutoIt,

or do i need to read it as a string and then explode the values or what would be a good way to read an XML file.

#include "MySQL.au3"
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <ListboxConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Dim $NameList
Dim $UserName=          "user"
Dim $Password=          "pass"
Dim $Database=          "db"
Dim $MySQLServerName=   "host"
Dim $TableName=         "table"

$SQLInstance=           _MySQLConnect($UserName, $Password, $Database, $MySQLServerName)

$GUI = GUICreate("Sync Tool", 298, 108, 700, 202)

$tekstLabel = GUICtrlCreateLabel("Synchroniseer je savegame met het systeem!", 8, 8, 283, 17)

$savegameCombo = GUICtrlCreateCombo("Selecteer je savegame...", 8, 48, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Savegame 1|Savegame 2|Savegame 3|Savegame 4|Savegame 5|Savegame 6|Savegame 7|Savegame 8|Savegame 9|Savegame 10")

$SynchroniseerButton = GUICtrlCreateButton("Synchroniseer", 8, 72, 75, 25)


GUISetState(@SW_SHOW)

; Events for Objects.
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $savegameCombo
            
        Case $SynchroniseerButton
            MsgBox("", "Box", "savegame" & $savegameCombo)
    EndSwitch
WEnd

; Functions
Func DisplayTable()
    $NameList=          ""
    $SQLCode=           "SELECT * FROM " & $TableName
    $TableContents=     _Query($SQLInstance, $SQLCode)
    With $TableContents
        While Not .EOF
            $NameList &= .Fields ("naam").value & " " & .Fields ("ingame").value & @CRLF
            .MoveNext
        WEnd
    EndWith
    MsgBox(0, "Gebruikers", $NameList)
EndFunc

_MySQLEnd($SQLInstance)
Link to comment
Share on other sites

The value in the variable $savegameCombo is the control id of the combo box, not its contents. Try this instead:

MsgBox("", "Box", "savegame :" & GUICtrlRead($savegameCombo))

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You could try and see if that UDF might be of use to you in reading the XML files.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You could try and see if that UDF might be of use to you in reading the XML files.

I'm experimenting with it at this moment, though I'm used to programming in PHP and reading XML there is quite a bit easier it seems, hehe.

I'm not quite getting trough it yet.

Currently have this, but how do i generated an array or get the values that i would need.

$savegameValue = StringLower(StringReplace(GUICtrlRead($savegameCombo), " ", ""))
$savegamePath = @MyDocumentsDir & "\My Games\FarmingSimulator2011\" & $savegameValue & "\careerSavegame.xml"
$gameinfoPath = @MyDocumentsDir & "\My Games\FarmingSimulator2011\savegames.xml"

$savegameXML = _XMLFileOpen($savegamePath)
$mapId = _XMLGetAttrib('./careerSavegame', 'mapId')
MsgBox("", "Map", $mapId)

This is an savegame xml file, the only things i would need are the value's of money, mapId.

There's another xml file that i would need to parse, but i'll probably get that sorted if i get a little help parsing this one :x

<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<careerSavegame revision="1" valid="true" money="99999994144150" dayTime="777.703796" playTime="601.955261" densityMapRevision="1" resetVehicles="false" mapId="FriskysFarmV3.SampleModMap" difficulty="1" autoBackupIndex="6" fuelUsage="1045.632935" seedUsage="0.000000" traveledDistance="233.656342" hectaresSeeded="0.000000" seedingDuration="0.000000" hectaresThreshed="12.341396" threshingDuration="76.467377" revenue="0.000000" expenses="2470.693604" numCows="20" milkProductionScale="1.000000" milkPriceScale="1.000000" manureProductionScale="1.000000" timeUntilNextRain="1146.296143" timeUntilRainAfterNext="6973.000000" rainTime="0.000000" nextRainDuration="266.000000" nextRainType="1" rainTypeAfterNext="0" nextRainValid="true" currentDay="16" saveDate="12.29.2010" foundBottleCount="0" deliveredBottles="0" foundBottles="0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" reputation="0" foundInfoTriggers="00000000000000000000">
    <farmSiloAmounts count="11">
        <farmSiloAmount fillType="grass" amount="44827.718750" />
        <farmSiloAmount fillType="maize" amount="17624.000000" />
        <farmSiloAmount fillType="barley" amount="37992.894531" />
        <farmSiloAmount fillType="rape" amount="49977.582031" />
        <farmSiloAmount fillType="manure" amount="93333.335938" />
        <farmSiloAmount fillType="dryGrass" amount="0.000000" />
        <farmSiloAmount fillType="milk" amount="666666.687500" />
        <farmSiloAmount fillType="chaff" amount="46133.976563" />
        <farmSiloAmount fillType="unknown" amount="0.000000" />
        <farmSiloAmount fillType="wheat" amount="18109.208984" />
        <farmSiloAmount fillType="liquidManure" amount="116666.664063" />
    </farmSiloAmounts>
    <fruitPrices count="7">
        <fruitPrice fruitType="wheat" price="0.576000" yesterdaysPrice="0.522000" />
        <fruitPrice fruitType="maize" price="0.345000" yesterdaysPrice="0.430000" />
        <fruitPrice fruitType="chaff" price="0.503000" yesterdaysPrice="0.503000" />
        <fruitPrice fruitType="barley" price="0.476000" yesterdaysPrice="0.476000" />
        <fruitPrice fruitType="rape" price="0.449000" yesterdaysPrice="0.511000" />
        <fruitPrice fruitType="grass" price="0.268000" yesterdaysPrice="0.268000" />
        <fruitPrice fruitType="dryGrass" price="0.369000" yesterdaysPrice="0.438000" />
        <fruitPrice fruitType="rye" price="0.304000" yesterdaysPrice="0.304000" />
        <fruitPrice fruitType="sunflower" price="0.882000" yesterdaysPrice="0.826000" />
        <fruitPrice fruitType="wheat" price="0.576000" yesterdaysPrice="0.522000" />
        <fruitPrice fruitType="potato" price="0.581000" yesterdaysPrice="0.664000" />
        <fruitPrice fruitType="chaff" price="0.503000" yesterdaysPrice="0.503000" />
        <fruitPrice fruitType="sugarbeet" price="0.420000" yesterdaysPrice="0.420000" />
        <fruitPrice fruitType="chaff" price="0.400000" yesterdaysPrice="0.400000" />
    </fruitPrices>
</careerSavegame>
Edited by WackOo
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...