Hi,
I know how to build a dialog and use either combo box or list box to present a list of items for users to select.
That would work fine if the number of items is limited, i.e a dozen of so.
When the list is long, combo or list box won't work too well. I need to display a text file that contains 300 or so names for user to select. The text file would be updated regularly.
How can I do that?
Please help, thanks
Dialog and large selection
Moderators: JRL, Dorian (MJT support)
mydave,
I don't know why your questions pique my curiousity.
Try something like this:
IfFileExists>c:\~list_script~.scp
DeleteFile>c:\~list_script~.scp
EndIf
Dialog>Dialog1
Caption=Call up the list
Width=445
Height=250
Top=100
Left=CENTER
Label=Your dialog with a button that calls the list,120,72
Button=See List,184,176,75,25,3
EndDialog>Dialog1
show>dialog1,r
if>r=3,Update
if>r=2,exit
Wait>0.2
Macro>c:\~list_script~.scp
Let>list_result=list_var_%MACRO_RESULT%
MDL>%list_result%
Wait>1
SRT>Update
Let>k=0
//Change c:\testtextfile.txt in the line below to the file that contains your data list.
ReadFile>c:\testtextfile.txt,list
Separate>list,%CRLF%,list_var
WriteLn>c:\~list_script~.scp,wresult,Dialog>DialogList
WriteLn>c:\~list_script~.scp,wresult,Caption=Pick from list
WriteLn>c:\~list_script~.scp,wresult,Width=400
WriteLn>c:\~list_script~.scp,wresult,Height=600
WriteLn>c:\~list_script~.scp,wresult,Top=100
WriteLn>c:\~list_script~.scp,wresult,Left=CENTER
Repeat>k
Let>k=k+1
Let>ypos=30*%k%
Let>bname=list_var_%k%
WriteLn>c:\~list_script~.scp,wresult,Button=%bname%,10,%ypos%,380,25,%k%
Until>k,list_var_count
WriteLn>c:\~list_script~.scp,wresult,EndDialog>DialogList
WriteLn>c:\~list_script~.scp,wresult,show>DialogList,MACRO_RESULT
WriteLn>c:\~list_script~.scp,wresult,CloseDialog>DialogList
END>Update
Label>exit
Edit-1
Changed "Dialog2" to a name less likely to be duplicated, "DialogList"
Hope this makes sense and that it works for you,
Dick
I don't know why your questions pique my curiousity.
Try something like this:
IfFileExists>c:\~list_script~.scp
DeleteFile>c:\~list_script~.scp
EndIf
Dialog>Dialog1
Caption=Call up the list
Width=445
Height=250
Top=100
Left=CENTER
Label=Your dialog with a button that calls the list,120,72
Button=See List,184,176,75,25,3
EndDialog>Dialog1
show>dialog1,r
if>r=3,Update
if>r=2,exit
Wait>0.2
Macro>c:\~list_script~.scp
Let>list_result=list_var_%MACRO_RESULT%
MDL>%list_result%
Wait>1
SRT>Update
Let>k=0
//Change c:\testtextfile.txt in the line below to the file that contains your data list.
ReadFile>c:\testtextfile.txt,list
Separate>list,%CRLF%,list_var
WriteLn>c:\~list_script~.scp,wresult,Dialog>DialogList
WriteLn>c:\~list_script~.scp,wresult,Caption=Pick from list
WriteLn>c:\~list_script~.scp,wresult,Width=400
WriteLn>c:\~list_script~.scp,wresult,Height=600
WriteLn>c:\~list_script~.scp,wresult,Top=100
WriteLn>c:\~list_script~.scp,wresult,Left=CENTER
Repeat>k
Let>k=k+1
Let>ypos=30*%k%
Let>bname=list_var_%k%
WriteLn>c:\~list_script~.scp,wresult,Button=%bname%,10,%ypos%,380,25,%k%
Until>k,list_var_count
WriteLn>c:\~list_script~.scp,wresult,EndDialog>DialogList
WriteLn>c:\~list_script~.scp,wresult,show>DialogList,MACRO_RESULT
WriteLn>c:\~list_script~.scp,wresult,CloseDialog>DialogList
END>Update
Label>exit
Edit-1
Changed "Dialog2" to a name less likely to be duplicated, "DialogList"
Hope this makes sense and that it works for you,
Dick
Last edited by JRL on Tue Feb 14, 2006 11:05 pm, edited 1 time in total.
Thanks Dick,
I've been working on your script for a while now, I think that I understand your logic, but not yet able to run the script properly, without the error "error trying to create dialog: Dialog2".
It is strange, since the script '~list_script~.scp' seemed to be created fine, and the dialogs seemed to be good too.
Still trying
I've been working on your script for a while now, I think that I understand your logic, but not yet able to run the script properly, without the error "error trying to create dialog: Dialog2".
It is strange, since the script '~list_script~.scp' seemed to be created fine, and the dialogs seemed to be good too.
Still trying
mydave,
Does "~list_script~.scp" run on its own? You should be able to double click it from explorer if the .scp extension is associated with Macro Scheduler. If it does not run, can you post the ~list_script~.scp so I can take a look at it.
If there is something in there that is secret or proprietary you can PM to me or send it to support and let MJTnet look at it.
I haven't figured out how to duplicate your error.
I'll keep trying as well.
Later,
Dick
Does "~list_script~.scp" run on its own? You should be able to double click it from explorer if the .scp extension is associated with Macro Scheduler. If it does not run, can you post the ~list_script~.scp so I can take a look at it.
If there is something in there that is secret or proprietary you can PM to me or send it to support and let MJTnet look at it.
I haven't figured out how to duplicate your error.
I'll keep trying as well.
Later,
Dick
OK, I think I've found it.
Dialog2 already exists in your main script. Even though we are writing a whole new script, for some reason that is in conflict. Change the name of the dialog being created in the "Update" subroutine to something that does not already exist in your main script.
Hope this helps,
Dick
Dialog2 already exists in your main script. Even though we are writing a whole new script, for some reason that is in conflict. Change the name of the dialog being created in the "Update" subroutine to something that does not already exist in your main script.
Hope this helps,
Dick
LOL, your script is working perfectly.
The reason for the error was that the list contains names, with Lastname, Firstname.
The coma's caused the script to fail, as they caused conflict with the coma's that defined buttons' locations.
Darn! this is elegant.
This is the second time that you gave me the magic! You know that?
I think this help a lot other people as well.
I'll use this script to build an user-self-setup. User runs the script and select their own name. Subsequent routines will write a startup file, which will enable user to automatically receive data from their own folder in a network.
I got more work to do, and I hope that this script is the only one that I need the magic from you. We'll see.
Thanks gain,
The reason for the error was that the list contains names, with Lastname, Firstname.
The coma's caused the script to fail, as they caused conflict with the coma's that defined buttons' locations.
Darn! this is elegant.
This is the second time that you gave me the magic! You know that?
I think this help a lot other people as well.
I'll use this script to build an user-self-setup. User runs the script and select their own name. Subsequent routines will write a startup file, which will enable user to automatically receive data from their own folder in a network.
I got more work to do, and I hope that this script is the only one that I need the magic from you. We'll see.
Thanks gain,