AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DDL ini file entry

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
BradleyS



Joined: 20 Sep 2005
Posts: 100

PostPosted: Sat Aug 16, 2008 9:49 am    Post subject: DDL ini file entry Reply with quote

Hi

I wonder if someone can help me resolve this issue I have with a DDL reading the information from an ini file.

All the other fields (edit, checkbox) read from the ini file OK.
I just can't figure out why the DDL doesn't work the same way.

Working code shown below:

Code:
#NoEnv
#SingleInstance force

IfNotExist C:\MyFiles
   FileCreateDir, C:\MyFiles
SetWorkingDir, C:\MyFiles

IniRead, FirstNum, MySettings.ini, 1stNum, FirstNum, %A_space%
Gui, Add, Edit, x12 y18 w135 h20 vFirstNum, %FirstNum%

IniRead, SecondNum, MySettings.ini, 2ndNum, SecondNum, %A_space%
Gui, Add, Edit, x12 y38 w135 h20 vSecondNum, %SecondNum%

IniRead, MyItems, MySettings.ini, DDL, MyItems, 0
Gui, Add, DDL, vMyItems Choose%MyItems%, Item 1|Item 2|Item 3

IniRead, MyBox, MySettings.ini, Tickbox, MyBox, 0
Gui, Add, Checkbox, gMyBox vMyBox Checked%MyBox%

Gui, Add, Button, w50 h20 gOK, OK
Gui, Show

MyBox:
GuiControlGet, MyBox, , MyBox
If MyBox=1
{
Gui, Submit, NoHide
GuiControl, Enable%MyBox%, MyItems
return
}
If MyBox=0
{
GuiControl, Enable%MyBox%, MyItems
return
}
return

!b::
OK:
Gui, Submit  ; Save the input from the user to each control's associated variable.
Iniwrite, %FirstNum%, MySettings.ini, 1stNum, FirstNum
Iniwrite, %SecondNum%, MySettings.ini, 2ndNum, SecondNum
Iniwrite, %MyItems%, MySettings.ini, DDL, MyItems
Iniwrite, %MyBox%, MySettings.ini, Tickbox, MyBox



ExitApp
Back to top
View user's profile Send private message
svi



Joined: 09 Oct 2006
Posts: 126
Location: Finland

PostPosted: Sat Aug 16, 2008 12:26 pm    Post subject: Reply with quote

The Manual wrote:
Alternatively, include in Options the word Choose followed immediately by the number to pre-select.

So, you have to extract the number by using eg. StringSplit:

Code:
IniRead, MyItems, MySettings.ini, DDL, MyItems, 0
StringSplit, number, MyItems, %A_Space%
Gui, Add, DDL, vMyItems Choose%number2%, Item 1|Item 2|Item 3

For other readers: DDL means DropDownList

Edit: Added morer color +:
If you were going to change item texts to have no numbers, then the simpliest way could be using arrays, but if the text contains a space, then it'll be more complicated (but not difficult).

Edit2:
I thougth there could be another way, and found option AltSubmit, which makes it posiible to use arrays also when the item texts contain spaces.
_________________
Pekka Vartto
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group