Jump to content
Sign in to follow this  

Issues with two input boxes calling a single function

Recommended Posts


I have been working on an issue for the past couple of hours, and seem to be painting myself into a corner. I know the resolution is simple, but I am not coming up with it. If anyone has any suggestions I would appreciate it.

Setup: The script creates a GUI that has a listview, and a number of input boxes. In the lower half of the GUI (see screenshot) I have two inputs and a "search" button. The end user puts in a partial PC name, and hits search; and the script queries a SQL database for all machines matching the input. The user can then select a machine and hit an "add" button, and the machine's full name is added to the correct input box. Rather than having three search buttons on the GUI, or calling three different functions, I opted for a Case statement:

If Search is pushed
Case SourcePC and DestinationPC = ""
     Msgbox("Please enter something in one field")
Case SourcePC and DestinationPC <> ""
     Msgbox("Please search one field at a time.")

Once past these statements, if the SourcePC is not "", a volatile variable is created that points to the SourcePC input field, and the function is called passing that variable. Same with the DestinationPC.

Case SourcePC <> ""
     $localVar = SourcePC

This all works great. The problem comes in once the user has done his first search, and one of the fields is populated. Then when the user enters a partial into the second input box, they're meeting the first case statement and receive a pop up to "Search only one field at a time"

I've attached a small reproducer. It should be easy enough to use a single function, but it seems to be eluding me. I thought about adding another temp variable ($searchlevel = 0) at the beginning, and then incrementing this whenever a search function is called. I'm hoping, however, for a better approach, as I would need to keep track of that variable and set it back to 0 before the user initiated another search. If the user just cleared the inputbox, I'm not sure how I'd capture this.


Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this