Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Populate combo from INI
#1
Hi,

I'm trying to populate a combo control from a an INI file.

I can get it to work using separate INI key/value pairs for each item and concat'ing them in the macro using 'cb3.from(item1[]item2...etc) but can't get it to work using a single line like below.

What I need is to be able to add more items at any time thru the INI and have the EXE pick them up.

Using the below method, all the items end up on the same line -- QM seems to treat the brackets in the INI-imported as escaped text (unlike as line/item breaks when the "cb3 =" line originates from the macro). I've been trying an array method but not quite able to get it to work yet... Thanks for any help!

S

(edit): I am trying to avoid having to switch to XML as the INI (created as part of fairly complex install routine) has 50+ items in it, with corresponding entries in the macro and it would be a major drag to have to redo it all...

c:\combo.ini:
Code:
Copy      Help
[COMBO]
cb3="one[]two[]three"

Macro
Code:
Copy      Help
str controls = "3"
str cb3
rget(cb3 "cb3" "combo" "c:\combo.ini")
if(!ShowDialog("Dropdown" &Dropdown &controls)) ret
out cb3

And example dialog:

Function Dropdown
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 ComboBox 0x54230243 0x0 56 38 104 213 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#2
cb3.escape(0)
#3
Thanks!

I also just got it to work by changing the brackets in the INI to a dash and using the line:
cb3.replacerx("--" "[]")
#4
And to get just the number value, be it one or two digits, and not the text from the ret value?
#5
What number?
#6
Sorry - The returned value from the combo dlg in the example (cb3 = "one[]two[]three") looks like this:

0 one

I need to separate the return string into two strings - the integer and the text. Reading about regex right now, but I thought I'd ask since you're around.

Thanks!
#7
OK, found the tok function...

Thanks again!


Forum Jump:


Users browsing this thread: 2 Guest(s)