Question about WIL Dialog Drop-Down Combo Box Control

Started by MrLeadFoot, July 30, 2016, 05:25:47 PM

Previous topic - Next topic

MrLeadFoot

I was wondering if someone could help shed some light on the implementation of this control. I can't seem to wrap my head around the instructions provided for this function.

I understand the concept of having an Edit Box and an Item Select Box in one control, but the help says that both the functions use the same variable. Let's say I have a script that has 3 items I want displayed in the list portion of the control a user can select from, but if the user wants an item that is not in that list, the user can enter a different item in the edit box, which makes perfect sense. According to the Help, I should place the 3 items into [variable] for the "pick" list. If the user selects an item from the list, my script would continue processing and use the selected item. So far so good. If the user wants a different item, the user would enter different item in the control's edit box thereby replacing what's set in [variable] with the value the user entered, and my script would continue processing based on what the user entered. Again, no problem here.

The confusion for me here is what if the user does NOT select an item from the list, and does NOT enter a different item in the edit box? I would want my script to see nothing in that [variable], but from what I gather from the wording in the Help, wouldn't [variable] still hold the 3 items I previously placed into [variable]?

USMuscle

I might be late to the party here, but I had the same question about this control, and also found that the documentation didn't really answer the question. I don't know technically how it happens, but what I found is that the control variable appears to only hold data temporarily to initially populate the list upon "loading" the control. After that, the variable somehow seems to empty itself, or something. Like I said, I don't know it does that, but if the user doesn't choose an item from the list, and doesn't enter anything in the field, the variable is empty. So this control will do exactly what you want. Create a simple test script, and you'll see what I mean.

For what it's worth, I've found that the documentation of some other functions also leaves some questions unanswered as well, and the only way to know for sure how those functions work is to setup a test script. While the documentation might leave you with questions about some functions here and there, I, personally, think that it's worth the effort to setup test scripts to test these functions because, in the end, winbatch is quite an awesome tool.  ;)

Hope this helps.

JTaylor

From the Help:

   "The users choice is placed in the variable named in the Variable attribute when the dialog is dismissed.    "

If nothing is in the editbox portion then the value of the variable is blank.   Of course, if you are using a Dynamic Dialog the "Dismissed" part may not apply but you would still get a blank value if you queried the control and the editbox was empty.


Jim

USMuscle

I think the OP was asking because the control only has one variable that behaves quite uniquely, as compared to how a variable typically works. The variable in this particular context seems to be used for two purposes simultaneously. The first use is to set the variable with the items to be displayed in the list. But, then, without doing anything else,  that same variable "magically" becomes empty when the dialog is displayed, and is used for what is, or is not, selected from the list or entered in the editbox. It almost doesn't make sense, in that if the variable initially contains the list items, how can it suddenly be empty if nothing is selected or entered? Because the typical behavior of a variable is such that once set to hold data the variable maintains that data until something changes the variable, you would think that if this control's variable holds list items, the variable wouldn't be empty. By the same token, you would think that if the variable was empty how can it show items in the list? It's a way cool feature, but the Help doesn't really explain that part of it, which is why it can be questionable, just like it was for me, initally, until I tried it.  ;)

I've come to love this control, once I understood it.

td

Dialog control variables obey a very specific set of rules with regard to how they are populated when a dialog is dismissed and there are reasons why these rules exist...
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade