Raffav Posted December 6, 2012 Share Posted December 6, 2012 (edited) Hello, in the future i will use inputbox but for now is just for testing. I'am trying to find a way to make to verify the correct answer for the input box, so if one the inputbox doesn't met the requirement it will ask to reconfigure, and wont continue the script. the way i found to control the inputbox work fine if only one email is field, but i decide to allow more them on email . so i begin to find a way to make the control to work but using this way wont work so i'am asking for some ideas for make the control to work. because i doesn't find a solution sorry for bad English Thanks expandcollapse popup#include <String.au3> #include <Misc.au3> #include <File.au3> #include <Array.au3> $urNome = "" ; inbox 1 put a name $urNomePst = "" ; inbox 2 put filename $urTam = "" ; inbox 3 put the lim size $urEmail = "raffav@msn.com;raffaello@msn.com;raffavgmail.com" ; inbox 4 put the email use ; to put more than one email $uverifc = "" #region ### VERIFICA NOME ############################ (Usuario) If $urNome = "" Then ; check if the name is blank MsgBox(0, "Error", "Insira Um Nome de usuario Valido") ;error msg $uverifc = $uverifc + 3 ; add + 3 to the control ElseIf StringLen($urNome) <= 3 Then ; check if the name have less them 3 char MsgBox(16, "Erro", "Favor inserir um nome maior do que 3 carecter") $uverifc = $uverifc + 3 ; add + 3 to the control Else ;if is corrent than set the controll to + 2 MsgBox(0, "ok 1", "OK 1") $uverifc = $uverifc + 2 ; add + 2 to the control EndIf #endregion ### VERIFICA NOME ############################ (Usuario) #region ### VERIFICA NOME PST ############################ (Usuario) If $urNomePst = "" Then MsgBox(0, "Error", "Insira Um Nome de Pst Valido") $uverifc = $uverifc + 3 Else $urNomePst = $urNomePst $size = FileGetSize($urNomePst) If $size = 0 Then MsgBox(16, "FILESIZE", "Nome da pst: " & '"' & $urNomePst & '"' & "Não encontrado, Favor especificar o nome correto") $uverifc = $uverifc + 3 Else MsgBox(0, "ok 2", "OK 2") $uverifc = $uverifc + 2 EndIf EndIf #endregion ### VERIFICA NOME PST ############################ (Usuario) #region ### VERIFICA TAMANHO PST ############################ (Usuario) $nun = StringRegExp($urTam, "^[0-9.]+$") If $urTam = "" Then MsgBox(0, "Error", "Insira Um Tamanho Valido") $uverifc = $uverifc + 3 ElseIf $nun = 0 Then MsgBox(16, "Erro", " Erro no 3° Parametro: " & '=>"' & $urTam & '"<=' & @CRLF & "Somente Numeros e Pontos(.)") $uverifc = $uverifc + 3 ElseIf $urTam < 5 Or $urTam > 15 Then MsgBox(64, "Erro", "Favor use um valor entre 5 - 15 GB") $uverifc = $uverifc + 3 Else MsgBox(0, "ok 3", "OK 3") $uverifc = $uverifc + 2 EndIf #endregion ### VERIFICA TAMANHO PST ############################ (Usuario) #region ### VERIFICA EMAIL DE ENVIO ############################ (Usuario) Global $To_array = StringSplit($urEmail, ";") Global $e_un[$To_array[0] + 1][2] = [[$To_array[0], 0]] For $s = 1 To UBound($To_array) - 1 If Not StringRegExp($To_array[$s], "^[a-z0-9._%-]+@[a-z0-9].+[*]{0,4}[a-z]{2,4}+$") Then $e_un[$s][0] = $To_array[$s] MsgBox(16, "Error", $e_un[$s][0] & " Não é Valido " & @CRLF & " Insira Um E-mail de envio Valido") $e_un[$s][1] = 2 $uverifc = $uverifc + 3 Else MsgBox(0, "ok 4", "OK 4") $uverifc = $uverifc + 2 $e_un[$s][0] = $To_array[$s] $e_un[$s][1] = 1 EndIf Next For $s = 1 To UBound($To_array) - 1; MsgBox(0, "ver", $e_un[$s][1] & " " & $e_un[$s][0]) Next #endregion ### VERIFICA EMAIL DE ENVIO ############################ (Usuario) ;this here only will work if the email is only one, because if ther more then 2 correct email the $uverifc used for verify the answer will pass the correct answer below and will always sai that is not ok If $uverifc <> 8 Then MsgBox(0, "Error", "reconfigure " & $uverifc) ; all, or one of them don't met the requeriment. ElseIf $uverifc == 8 Then MsgBox(0, "ok 5", "Configuração Ok") ;all is ok so can continue the script EndIf Edited December 6, 2012 by Raffav Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted December 6, 2012 Share Posted December 6, 2012 I am having trouble following your script. But one of these is not an email "raffav@msn.com;raffaello@msn.com;raffavgmail.com" Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
Raffav Posted December 6, 2012 Author Share Posted December 6, 2012 I am having trouble following your script. But one of these is not an email"raffav@msn.com;raffaello@msn.com;raffavgmail.com"yes it wrong for propose of test, i will put comments in English so will help understandthis script, is for testing propose only,i am trying to find a way to make some type of verification ,if any one of the 4 inbutbox(dont exist at the moment, but it will in the furure) dont met the requirement the script wont continue until the requirement is met. Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted December 6, 2012 Share Posted December 6, 2012 Well the count will probably be wrong, because it will add to $uverifc, for each time it gets passed in the for...next loop. I would try to rewrite your script using fuctions and returns for error and flow handling rather than an integer variable. Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
kylomas Posted December 7, 2012 Share Posted December 7, 2012 Raffav, The following is one way to accept input and verify it. Keep in mind that there are many ways ot do this and this example is far from complete. It is just meant as an example. expandcollapse popup#include <guiconstants.au3> #include <String.au3> #include <String.au3> #include <Misc.au3> #include <File.au3> #include <Array.au3> ; because you are dealing with multiple input fields I recommend using input controls within a gui as opposed to running successive "InputBox" functions local $gui010 = guicreate('I Have No Idea What This Script Is Supposed To Do',600,200) guictrlcreatelabel('Name',10,10,50,20) guictrlcreatelabel('FileName',10,50,50,20) guictrlcreatelabel('UrTam',10,90,50,20) guictrlcreatelabel('Email',10,130,50,20) local $urNome = guictrlcreateinput('',70,10,200,20) local $urNomePst = guictrlcreateinput('',70,50,200,20) local $urTam = guictrlcreateinput('',70,90,200,20) local $urEmail = guictrlcreateinput('',70,130,200,20) local $urNomeW = guictrlcreatelabel('',300,10,250,20) guictrlsetcolor(-1,0xff0000) guictrlsetfont(-1,8,600) local $urNomePstW = guictrlcreatelabel('',300,50,250,20) guictrlsetcolor(-1,0xff0000) guictrlsetfont(-1,8,600) local $urTamW = guictrlcreatelabel('',300,90,250,20) guictrlsetcolor(-1,0xff0000) guictrlsetfont(-1,8,600) local $urEmailW = guictrlcreatelabel('',300,130,250,20) guictrlsetcolor(-1,0xff0000) guictrlsetfont(-1,8,600) guisetstate() while 1 switch guigetmsg() case $gui_event_close exit case $urNome _validate_UrNome(guictrlread($urNome)) ; reads the value of the control and passes it to the validation function case $urNomePst _validate_UrHomePst(guictrlread($urNomePst)) ; reads the value of the control and passes it to the validation function ;~ case $urTam ;~ _validate_UrTam(guictrlread($urTam)) ; reads the value of the control and passes it to the validation function ;~ case $urEmail ;~ _validate_UrEmail(guictrlread($urEmail)) ; reads the value of the control and passes it to the validation function EndSwitch wend func _validate_UrNome($string) If $string = "" Then ; check if the name is blank guictrlsetdata($urNomeW,'Enter Valid Name') guictrlsetstate($urNome,$gui_focus) Return endif If StringLen($string) <= 3 Then ; check if the name have less them 3 char guictrlsetdata($urNomeW,'Name Must Be At Least 3 Chars Long') guictrlsetstate($urNome,$gui_focus) Return EndIf endfunc func _validate_UrHomePst($string) If $string = "" Then guictrlsetdata($urNomePstW,'Enter Valid File Name') guictrlsetstate($urNomePst,$gui_focus) Return Else if not fileexists($string) then ; at this point you could run "fileopendialog" to allow the user to browse for a file guictrlsetdata($urNomePstW,'File Does Not Exist') guictrlsetstate($urNomePst,$gui_focus) Return endif $size = FileGetSize($string) If $size = 0 Then guictrlsetdata($urNomePstW,'File is 0 length') guictrlsetstate($urNomePst,$gui_focus) Return EndIf EndIf endfunc kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Raffav Posted December 7, 2012 Author Share Posted December 7, 2012 Raffav, The following is one way to accept input and verify it. Keep in mind that there are many ways ot do this and this example is far from complete. It is just meant as an example. expandcollapse popup#include <guiconstants.au3> #include <String.au3> #include <String.au3> #include <Misc.au3> #include <File.au3> #include <Array.au3> ; because you are dealing with multiple input fields I recommend using input controls within a gui as opposed to running successive "InputBox" functions local $gui010 = guicreate('I Have No Idea What This Script Is Supposed To Do',600,200) guictrlcreatelabel('Name',10,10,50,20) guictrlcreatelabel('FileName',10,50,50,20) guictrlcreatelabel('UrTam',10,90,50,20) guictrlcreatelabel('Email',10,130,50,20) local $urNome = guictrlcreateinput('',70,10,200,20) local $urNomePst = guictrlcreateinput('',70,50,200,20) local $urTam = guictrlcreateinput('',70,90,200,20) local $urEmail = guictrlcreateinput('',70,130,200,20) local $urNomeW = guictrlcreatelabel('',300,10,250,20) guictrlsetcolor(-1,0xff0000) guictrlsetfont(-1,8,600) local $urNomePstW = guictrlcreatelabel('',300,50,250,20) guictrlsetcolor(-1,0xff0000) guictrlsetfont(-1,8,600) local $urTamW = guictrlcreatelabel('',300,90,250,20) guictrlsetcolor(-1,0xff0000) guictrlsetfont(-1,8,600) local $urEmailW = guictrlcreatelabel('',300,130,250,20) guictrlsetcolor(-1,0xff0000) guictrlsetfont(-1,8,600) guisetstate() while 1 switch guigetmsg() case $gui_event_close exit case $urNome _validate_UrNome(guictrlread($urNome)) ; reads the value of the control and passes it to the validation function case $urNomePst _validate_UrHomePst(guictrlread($urNomePst)) ; reads the value of the control and passes it to the validation function ;~ case $urTam ;~ _validate_UrTam(guictrlread($urTam)) ; reads the value of the control and passes it to the validation function ;~ case $urEmail ;~ _validate_UrEmail(guictrlread($urEmail)) ; reads the value of the control and passes it to the validation function EndSwitch wend func _validate_UrNome($string) If $string = "" Then ; check if the name is blank guictrlsetdata($urNomeW,'Enter Valid Name') guictrlsetstate($urNome,$gui_focus) Return endif If StringLen($string) <= 3 Then ; check if the name have less them 3 char guictrlsetdata($urNomeW,'Name Must Be At Least 3 Chars Long') guictrlsetstate($urNome,$gui_focus) Return EndIf endfunc func _validate_UrHomePst($string) If $string = "" Then guictrlsetdata($urNomePstW,'Enter Valid File Name') guictrlsetstate($urNomePst,$gui_focus) Return Else if not fileexists($string) then ; at this point you could run "fileopendialog" to allow the user to browse for a file guictrlsetdata($urNomePstW,'File Does Not Exist') guictrlsetstate($urNomePst,$gui_focus) Return endif $size = FileGetSize($string) If $size = 0 Then guictrlsetdata($urNomePstW,'File is 0 length') guictrlsetstate($urNomePst,$gui_focus) Return EndIf EndIf endfunc kylomas Thanks, I will try your script when I return from travel, The script that I am making is to control the size of a file, Outlook pst, we don't use exchange so we use a Web mail and because receive a lot of file by email the pst goes quickly to 18gb and get corrupt, so I am making this script that will check the size of the pst and when is near to 15 gb it will send an email alert to the internal suport so they can create a new file. But this here is just test the validation control. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now