Dialog Listbox request
Moderators: Dorian (MJT support), JRL
Dialog Listbox request
Is there a way we can get the Listbox (double click selection) to work as a Control, simular to a button click?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
You can do that now. Variables are availble with the format %DialogName.ComboBoxName%. Here is an excerpt from a script where two combo boxes are used and decisions and navigation are based on selection of combo box.
Hope this helps, good luck.
....
....
Let>ComboHelp=Log Off allows Log on as a new user.%CRLF%Shut Down turns off power.%CRLF%Re Boot restarts computer
....
....
Dialog>WindowsExit
Caption=Shut Down Windows
Top=144
Width=315
Left=312
Height=230
Label=What do you want the computer to do?,56,16
Label=%ComboHelp%,34,72
Label=Reason:,21,112
Label=Enter Other Reason / optional Note,125,112
Button=OK,28,160,75,25,1
Button=Cancel,120,160,75,25,2
Button=Help,212,160,75,25,3
ComboBox=Action,82,40,145,Log Off%CRLF%Re Boot%CRLF%Shut Down
ComboBox=Reason,8,128,121,Normal-end of work%CRLF%Low Resources%CRLF%Problem noted here:%CRLF%Required by System%CRLF%Software Change%CRLF%System is hung%CRLF%Testing%CRLF%See Other Reason:
Edit=Other,136,128,164,
EndDialog>WindowsExit
//Prompt User to select method of Shutdown
Label>ShowWindow
Show>WindowsExit,Button
//Cancelling form will make Button=2
Goto>%Button%
//Help Button
Label>3
//Provide modal instructions
MessageModal>This is a HELP window to explain how this works
Goto>ShowWindow
//Cancel Button
Label>2
Goto>End2
//OK Button
Label>1
If>%WindowsExit.Action%=,Errors
If>%WindowsExit.Reason%=,Errors
If>%WindowsExit.Reason%See Other Reason:,Continue
If>%WindowsExit.Other%=,Errors,Continue
Label>Errors
MessageModal>Missing Action or Reason
Goto>ShowWindow
Label>Continue
Goto>%WindowsExit.Action%
Label>Shut Down
Let>Choice=0
//Insert actions to run on Shut Down
WriteLn>c:\batch\logging.log,result,%Date%-%Time%:%USER_NAME% Shutting Down computer "%COMPUTER_NAME%.-//-%WindowsExit.Reason% %WindowsExit.Other%.
Run Program>C:\batch\ShutDown.bat
Goto>End
Label>Re Boot
Let>Choice=1
//Insert actions to run on Re Boot
WriteLn>c:\batch\logging.log,result,%Date%-%Time%:%USER_NAME% ReBooting computer "%COMPUTER_NAME%.-//-%WindowsExit.Reason% %WindowsExit.Other%.
Run Program>C:\batch\ReBoot.bat
Goto>End
Label>Log Off
Let>Choice=2
//Insert actions to run on Log Off
WriteLn>c:\batch\logging.log,result,%Date%-%Time%:%USER_NAME% Logging Out from "%COMPUTER_NAME%.-//-%WindowsExit.Reason% %WindowsExit.Other%.
Run Program>C:\batch\LogOff.bat
Goto>End
....
....
....
Label>End
ShutDownWindows>%Choice%
Label>End2
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Double click in listbox
Bob, thanks for the info. I see how you can make a selection perform an action, but I'm looking to double mouse click an item in a listbox and have it perform an action without having to click any buttons. Attached is an example of the listbox I'm using.
Dialog>MyDialog
Caption=This is My Dialog
Top=242
Width=518
Left=257
Height=362
Button=Display,48,78,41,203,3
Button=Exit Macro,405,34,100,20,2
ListBox=MyListBox1,96,80,200,200,Listbox1
ListBox=MyListBox2,304,80,200,200,Listbox2
EndDialog>MyDialog
Let>FirstRun=0
Let>Listbox1=Line One%CRLF%Line Two%CRLF%Line Three%CRLF%Line Four
Let>Listbox2=
Label>MainLoop
Show>MyDialog,result
If>result=2,End
If>result=3,SayHello
Goto>MainLoop
SRT>SayHello
If>FirstRun>0,AddCrlf
Add>FirstRun,1
Let>Listbox2=%MyDialog.MyListBox1%
Goto>MainLoop
Label>AddCrlf
ConCat>Listbox2,%CRLF%
ConCat>Listbox2,%MyDialog.MyListBox1%
END>SayHello
Label>End
Dialog>MyDialog
Caption=This is My Dialog
Top=242
Width=518
Left=257
Height=362
Button=Display,48,78,41,203,3
Button=Exit Macro,405,34,100,20,2
ListBox=MyListBox1,96,80,200,200,Listbox1
ListBox=MyListBox2,304,80,200,200,Listbox2
EndDialog>MyDialog
Let>FirstRun=0
Let>Listbox1=Line One%CRLF%Line Two%CRLF%Line Three%CRLF%Line Four
Let>Listbox2=
Label>MainLoop
Show>MyDialog,result
If>result=2,End
If>result=3,SayHello
Goto>MainLoop
SRT>SayHello
If>FirstRun>0,AddCrlf
Add>FirstRun,1
Let>Listbox2=%MyDialog.MyListBox1%
Goto>MainLoop
Label>AddCrlf
ConCat>Listbox2,%CRLF%
ConCat>Listbox2,%MyDialog.MyListBox1%
END>SayHello
Label>End
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
I may be wrong on this, but I think you may have a problem line here:
It also looks like a never ending loop may be possible with Main Menu and SRT>Say Hello where you go back to Main Menu and could call SRT>Say Hello again without ever getting to the End>SayHello line..
Hope this helps, good luck.........
These are just observations from a quick glance, I have not actually tried the script.
IF> only goes to labels, not to SRTs. I know there has been a request to change that in the future. In the meantime, you need to place a label before the SRT, then GoSub>SRT, and then GoTo>?? to continue when the SRT ends. That last Goto>?? would probably be on the line following the IF> statement that went to the SRT.If>result=3,SayHello
It also looks like a never ending loop may be possible with Main Menu and SRT>Say Hello where you go back to Main Menu and could call SRT>Say Hello again without ever getting to the End>SayHello line..
Hope this helps, good luck.........
These are just observations from a quick glance, I have not actually tried the script.
Last edited by Bob Hansen on Wed May 07, 2003 12:29 am, edited 2 times in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Bob,
You are incorrect. IF goes to Subroutines as well as labels.
From the help file:
If>expression,true_label_name[,false_label_name]
Causes execution to continue at the specified label, if expression is true, missing any commands in between. If the label does not exist an error message will be displayed. If a second false label is specified, execution will jump to that label if the expression resolves false. Subroutine names can also be specified. When specifying a subroutine name execution will jump to that subroutine and return when the subroutine has completed.
Regarding event handlers for objects, these are not supported at present so you cannot build an "On Click" event handler. We are looking into the feasibility of providing this in future but given the interpreted, sequential nature of a script language and the necessary modal qualities of dialogs, this represents some challenges. We are looking into providing non-modal forms with the ability to create a control loop and therefore allow a degree event handling.
You are incorrect. IF goes to Subroutines as well as labels.
From the help file:
If>expression,true_label_name[,false_label_name]
Causes execution to continue at the specified label, if expression is true, missing any commands in between. If the label does not exist an error message will be displayed. If a second false label is specified, execution will jump to that label if the expression resolves false. Subroutine names can also be specified. When specifying a subroutine name execution will jump to that subroutine and return when the subroutine has completed.
Regarding event handlers for objects, these are not supported at present so you cannot build an "On Click" event handler. We are looking into the feasibility of providing this in future but given the interpreted, sequential nature of a script language and the necessary modal qualities of dialogs, this represents some challenges. We are looking into providing non-modal forms with the ability to create a control loop and therefore allow a degree event handling.
MJT Net Support
[email protected]
[email protected]
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Oops, my mistake. I was remembering the earlier message that IFE> does not work with Subs. Sorry about that. Thanks for the correction.
And I never noticed the additional comments on IF> re subroutine labels. This will be great for me. Thanks for pointing that out.
And I never noticed the additional comments on IF> re subroutine labels. This will be great for me. Thanks for pointing that out.
Subroutine names can also be specified. When specifying a subroutine name execution will jump to that subroutine and return when the subroutine has completed.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Listbox double click
Thanks for the information. I'll leave things as they are for now. The users already got more than they ask for and I love the addition of the Dialog.