Sign in to follow this  
Followers 0
igorm

How to force inputbox not to be left empty?

10 posts in this topic

Hi.

I need a little help. I created one small application with few inputboxes, but I need to force user to enter the path to the folder (not to file). It would be good if I could display message to user if he/she did not enter the path. Can somebody help me with this please?

Tnx in advance for help.

Cheers :)

Share this post


Link to post
Share on other sites



Maybe it'd be better if you used FileSelectFolder. It does what you want.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi.

I need a little help. I created one small application with few inputboxes, but I need to force user to enter the path to the folder (not to file). It would be good if I could display message to user if he/she did not enter the path. Can somebody help me with this please?

Tnx in advance for help.

Cheers :)

The solution you require for this is probably tooltips the following is an example:

$ExitButton = GUICtrlCreateIcon("shell32.dll", 240, 450, 240, 40, 35)

GUICtrlSetTip(-1, " Exit", "Help", 1, 1)

In this example the reference to shell32.dll,240 determines what the control look like in the case a fancy X. The control itself can be an inputbox or a button or any of the other types. When the mouse pointer floats over the control then the tip is displayed in a message box. In the case the message is "Exit" it can be whatever you would like it to be you can use @crlf or @ lf to start text on new lines in the box this is an example

GUICtrlSetTip(-1, " Exit" & @crlf & @lf & "This is the additional message", "Help", 1, 1)

The input error trap would be accommodated in the control routine

$inputbox1 = GUICtrlRead($nameforinputbox) ;read the input

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $ExitButton

GUIDelete()

Exit

Case $msg = "nameofyourinputbox"

"perform the input test based on if and or then"

Endselect

Wend

Hope that this gets you going

Cheers

Ant..

Edited by anixon

Share this post


Link to post
Share on other sites

Thank you for help, but it is not what I need. It seems that I did not explain quite well.

I have two inputboxes. One is for folder browsing (I used FileSelectFolder).

Second one is for selecting files (I used FileOpenDialog)

And I have one button which will execute something. But execution will fail if first inputbox is empty. So when user press button for execute and first inputbox is empty I need to display message that path is not entered and to stop execution activated by pressing button.

Hope you can help me now.

Thanks again.

Cheers :)

Share this post


Link to post
Share on other sites

read the text of the input box, and if that is "" then do something to stop the script or tell them it is empty.

Share this post


Link to post
Share on other sites

$folderimput=GUictrlcreateedit(blah blah)

*button is pressed*

If Guictrlread($folderimput)="" Then

MsgBox(0,"","You must enter a path")

Endif

Share this post


Link to post
Share on other sites

Then you would hvae to put the rest of your script in an else part of that if to keep it from running. eg:

If Guictrlread($folderimput)="" Then
MsgBox(0,"","You must enter a path")

Else
Rest of code
Endif

End of loop

Share this post


Link to post
Share on other sites

Nother way, if your using Funcs for each Q

Func questionOne()
$questionOneAns = Inputbox("Q1", "q1")
If $questionOneAns <> ""
questionTwo()
Else
MsgBox("Fail", "Failed to enter a directory")
questionOne()
EndFunc

then repeat the func for the 2nd question, modifying as needed.

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  
Followers 0