itemindex and radio buttons
Moderators: Dorian (MJT support), JRL
itemindex and radio buttons
Is there a way to set the Radio Button like setting the item in a drop down list. I have tried a few things with no sucess. I end up having to put a varialbe at the end of the line in the dialog. Although this works everytime the dialog is edited the variable has to be reentered, which is easy to forget.
- Marcus Tettmar
- Site Admin
- Posts: 7380
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Yes. Exactly the same. Set the ItemIndex property. From the help file:
To pre-select items in a ListBox, ComboBox or RadioGroup set the object's ItemIndex property. 0 is the first item. E.g. Let>MyDialog.msListBox1.ItemIndex=0
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Help with itemindex
Below is a typical script that always causes me problems as I am yet to fully understand the set itemindex as outlined in the help file.
This is what it says as shown in the previous post
Let>MyDialog.msListBox1.ItemIndex=0
So it should be set to the first one in the list. I have done this before and it has worked. However, I am missing something on this one
------------------------------ Script ----------------------
Let>comma=,
Let>delsep=:
Let>csvpath=c:\temp\txt.csv
If>%delsep%=,
Let>Browsecsv.ComboBox.ItemIndex=0
Endif
If>%delsep%=;
Let>Browsecsv.ComboBox.ItemIndex=1
Endif
If>%delsep%=;
Let>Browsecsv.ComboBox.ItemIndex=2
Endif
If>%delsep%=:
Let>Browsecsv.ComboBox.ItemIndex=3
Endif
Dialog>Browsecsv
Caption=Create Barcodes from CSV file
Width=362
Height=222
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=1
Resize=0
Image=C:\BatchBCCoverCreator\CSV Merge\createcsvmenu1.bmp,0,0,353,201,msImage1,0
Label=Enter the csv file to be processed,67,67,true
Label=Copyright© eDocFile Inc. 2004-2008,85,170,true
Button=Continue,103,136,75,25,1
Button=Exit,177,136,75,25,2
Edit=csvfile,23,88,234,%csvpath%
Button=Browse,263,87,75,23,0
ComboBox=delim,24,112,41,%comma%%CRLF%;%CRLF%:%CRLF%~
Label=Select Delimiter,72,116,true
FileBrowse=Browse,csvfile,PDF Files|*.csv|All Files|*.*,open
EndDialog>Browsecsv
Show>Browsecsv
Label>csvbrowsemenu
GetDialogAction>browsecsv,r
If>r=2,EOF
If>r=1,continue
Wait>0.1
Goto>csvbrowsemenu
Label>EOF
------------------------------------ End Script -------------------------------
Naturaly the values are actually read from an ini file, but when it comes to the debugger it says BROWSECSV.COMBOBOX.ITEMINDEX=3
write before it comes to the Browsecsv box. So it should be set and it is not.
If someone has some time a good explaination of this would be nice. Something like was done on when to use %% around variables. With this script I have spent more time on this one issue than writing the other 300 lines that do work.
Thanks for any assistance in advance
This is what it says as shown in the previous post
Let>MyDialog.msListBox1.ItemIndex=0
So it should be set to the first one in the list. I have done this before and it has worked. However, I am missing something on this one
------------------------------ Script ----------------------
Let>comma=,
Let>delsep=:
Let>csvpath=c:\temp\txt.csv
If>%delsep%=,
Let>Browsecsv.ComboBox.ItemIndex=0
Endif
If>%delsep%=;
Let>Browsecsv.ComboBox.ItemIndex=1
Endif
If>%delsep%=;
Let>Browsecsv.ComboBox.ItemIndex=2
Endif
If>%delsep%=:
Let>Browsecsv.ComboBox.ItemIndex=3
Endif
Dialog>Browsecsv
Caption=Create Barcodes from CSV file
Width=362
Height=222
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=1
Resize=0
Image=C:\BatchBCCoverCreator\CSV Merge\createcsvmenu1.bmp,0,0,353,201,msImage1,0
Label=Enter the csv file to be processed,67,67,true
Label=Copyright© eDocFile Inc. 2004-2008,85,170,true
Button=Continue,103,136,75,25,1
Button=Exit,177,136,75,25,2
Edit=csvfile,23,88,234,%csvpath%
Button=Browse,263,87,75,23,0
ComboBox=delim,24,112,41,%comma%%CRLF%;%CRLF%:%CRLF%~
Label=Select Delimiter,72,116,true
FileBrowse=Browse,csvfile,PDF Files|*.csv|All Files|*.*,open
EndDialog>Browsecsv
Show>Browsecsv
Label>csvbrowsemenu
GetDialogAction>browsecsv,r
If>r=2,EOF
If>r=1,continue
Wait>0.1
Goto>csvbrowsemenu
Label>EOF
------------------------------------ End Script -------------------------------
Naturaly the values are actually read from an ini file, but when it comes to the debugger it says BROWSECSV.COMBOBOX.ITEMINDEX=3
write before it comes to the Browsecsv box. So it should be set and it is not.
If someone has some time a good explaination of this would be nice. Something like was done on when to use %% around variables. With this script I have spent more time on this one issue than writing the other 300 lines that do work.
Thanks for any assistance in advance
Hi kpassaur,
This works. I don't have time right now for a lengthy explanation but I would like to comment that Marcus' blog on percents usage is excellent.
I think the main point you're missing is that you renamed the combo box to "delim" but you call the item index "Browsecsv.ComboBox.ItemIndex". You need to call "Browsecsv.delim.ItemIndex".
A second point is that you define the variable "Browsecsv.delim.ItemIndex" before the dialog block exists. When the dialog block is defined it will reset the value of "Browsecsv.delim.ItemIndex" back to the default which is 0.
Step through the following and step through what you posted and you should be able to see the differences.
Good luck,
Dick
This works. I don't have time right now for a lengthy explanation but I would like to comment that Marcus' blog on percents usage is excellent.
I think the main point you're missing is that you renamed the combo box to "delim" but you call the item index "Browsecsv.ComboBox.ItemIndex". You need to call "Browsecsv.delim.ItemIndex".
A second point is that you define the variable "Browsecsv.delim.ItemIndex" before the dialog block exists. When the dialog block is defined it will reset the value of "Browsecsv.delim.ItemIndex" back to the default which is 0.
Step through the following and step through what you posted and you should be able to see the differences.
Good luck,
Dick
Code: Select all
Let>sep_0=,
Let>sep_1=;
Let>sep_2=:
Let>sep_3=~
Let>delsep=:
Let>seplist=
Let>kk=-1
Repeat>kk
Add>kk,1
Let>sep=sep_%kk%
If>%sep%=%delsep%
Let>index=%kk%
EndIf
Concat>seplist,%sep%%CRLF%
Until>kk,3
Let>csvpath=c:\temp\txt.csv
Dialog>Browsecsv
Caption=Create Barcodes from CSV file
Width=362
Height=222
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=1
Resize=0
Image=C:\BatchBCCoverCreator\CSV Merge\createcsvmenu1.bmp,0,0,353,201,msImage1,0
Label=Enter the csv file to be processed,67,67,true
Label=Copyright© eDocFile Inc. 2004-2008,85,170,true
Button=Continue,103,136,75,25,1
Button=Exit,177,136,75,25,2
Edit=csvfile,23,88,234,%csvpath%
Button=Browse,263,87,75,23,0
ComboBox=delim,24,112,233,%seplist%
Label=Select Delimiter,264,116,true
FileBrowse=Browse,csvfile,PDF Files|*.csv|All Files|*.*,open
EndDialog>Browsecsv
Show>Browsecsv
GetDialogAction>browsecsv,r
Let>Browsecsv.delim.ItemIndex=%index%
ResetDialogAction>Browsecsv
Label>csvbrowsemenu
GetDialogAction>browsecsv,r
If>r=2,EOF
If>r=1,continue
Wait>0.1
Goto>csvbrowsemenu
Label>EOF