Populating a combobox list from an ini file

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
spodster
Newbie
Posts: 1
Joined: Fri Feb 02, 2007 10:40 am

Populating a combobox list from an ini file

Post by spodster » Fri Feb 02, 2007 11:30 am

Apologies for any bad scripting, but this is my first effort at any kind of programming since my Sinclair ZX81!

I've made a dialog box, and i'm trying to get it to use the last settings that were recorded by using an ini file. I've managed to get the checkboxes to read the ini file, but i haven't a clue on how to get the comboboxes to read from the ini and to have the last selection pre-selected.

Here's the ini file and the code for the dialog box:

Code: Select all

// ini file text from here

[settings]
SB_LONGINI=True
SB_SHORTINI=True
EX_LONGINI=True
EX_SHORTINI=True
CLOSE_APINI=True
S_DOWNINI=True
MOVE_BEINI=True
NO_OF_TRADESINI=2
NO_OF_TRADESINI=5
NO_HOURSINI=2
OPEN_OANDAINI=False
OPEN_SFSINI=False


// Dialog code from here

ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,SB_LONGINI,SB_LONGVAL
ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,SB_SHORTINI,SB_SHORTVAL
ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,EX_LONGINI,EX_LONGVAL
ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,EX_SHORTINI,EX_SHORTVAL
ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,CLOSE_APINI,CLOSE_APVAL
ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,S_DOWNINI,S_DOWNVAL
ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,NO_OF_TRADESINI,NO_OF_TRADESVAL
ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,NO_HOURSINI,NO_HOURSVAL
ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,MOVE_BEINI,MOVE_BEVAL
ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,OPEN_OANDAINI,OPEN_OANDAVAL
ReadIniFile>C:\program files\autotrade\autotrade.ini,settings,OPEN_SFSINI,OPEN_SFSVAL


Dialog>OPTIONS_BOX
   Caption=Title
   Width=401
   Height=602
   Top=146
   Left=672
   Max=1
   Min=1
   Close=1
   Resize=1
   Label=Title Here,98,16,true
   Label=Please enter your choices below,32,48,true
   CheckBox=SB_LONG,Standby for Long,32,72,137,SB_LONGVAL
   CheckBox=SB_SHORT,Standby for Short,32,104,153,SB_SHORTVAL
   CheckBox=EX_LONG,Excute Long,32,136,137,EX_LONGVAL
   CheckBox=EX_SHORT,Execute Short,32,168,161,EX_SHORTVAL
   CheckBox=CLOSE_AP,Close all positions,32,200,161,CLOSE_APVAL
   CheckBox=S_DOWN,Stand down,32,232,161,S_DOWNVAL
   CheckBox=MOVE_BE,Move to Break Even,32,264,193,MOVE_BEVAL
   Button=OK,104,520,75,25,1
   Button=Cancel,200,520,75,25,2
   ComboBox=NO_HOURS,32,392,313,0%CRLF%1%CRLF%2%CRLF%3%CRLF%4%CRLF%5%CRLF%6%CRLF%7%CRLF%8%CRLF%9%CRLF%10%CRLF%11%CRLF%12%CRLF%-1%CRLF%-2%CRLF%-3%CRLF%-4%CRLF%-5%CRLF%-6%CRLF%-7%CRLF%-8%CRLF%-9%CRLF%-10%CRLF%-11%CRLF%-12
   ComboBox=NO_OF_TRADES,32,336,313,1%CRLF%2
   Label=Please enter the number,32,312,true
   Label=Please enter your time difference in hours to US EST:,32,368,true
   CheckBox=OPEN_OANDA,Open OANDA Login?,32,432,153,OPEN_OANDAVAL
   CheckBox=OPEN_SFS,Open SFS Login?,32,464,209,OPEN_SFSVAL
   Font=arial,8
EndDialog>OPTIONS_BOX


Label>DialogLoop
Show>OPTIONS_BOX,result
If>result=1,SET_WINDOWS
If>result=2,end_prog
Goto>DialogLoop


Label>SET_WINDOWS
EditIniFile>C:\program files\autotrade\autotrade.ini,settings,SB_LONGINI,%OPTIONS_BOX.SB_LONG%
EditIniFile>C:\program files\autotrade\autotrade.ini,settings,SB_SHORTINI,%OPTIONS_BOX.SB_SHORt%
EditIniFile>C:\program files\autotrade\autotrade.ini,settings,EX_LONGINI,%OPTIONS_BOX.EX_LONG%
EditIniFile>C:\program files\autotrade\autotrade.ini,settings,EX_SHORTINI,%OPTIONS_BOX.EX_SHORT%
EditIniFile>C:\program files\autotrade\autotrade.ini,settings,CLOSE_APINI,%OPTIONS_BOX.CLOSE_AP%
EditIniFile>C:\program files\autotrade\autotrade.ini,settings,S_DOWNINI,%OPTIONS_BOX.S_DOWN%
EditIniFile>C:\program files\autotrade\autotrade.ini,settings,NO_OF_TRADESINI,%OPTIONS_BOX.NO_OF_TRADES%
EditIniFile>C:\program files\autotrade\autotrade.ini,settings,MOVE_BEINI,%OPTIONS_BOX.MOVE_BE%
EditIniFile>C:\program files\autotrade\autotrade.ini,settings,OPEN_OANDAINI,%OPTIONS_BOX.OPEN_OANDA%
EditIniFile>C:\program files\autotrade\autotrade.ini,settings,OPEN_SFSINI,%OPTIONS_BOX.OPEN_SFS%

Label>end_prog
The combobox choices for NO_OF_TRADES should be 1 or 2. The combobox choices for NO_HOURS should be 0 through to 12 and -1 through to -12.

Any ideas?

Your help would be most appreciated.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts