Tiboi Posted May 25, 2010 Share Posted May 25, 2010 this code is not giving me my desired output can someone help me please? Global $txtName = "name", $txtAddress = "address", $txtAge = "age", $txtSex = "male" If $txtName Or $txtAddress = "" Then ;<-- if these $txtName Or $txtAddress is empty, an error should show ERROR_MSG() ElseIf $txtName Or $txtAddress > "" And $txtAge Or $txtSex = "" Then ;<-- if both $txtName and $txtAddress is full save them to the ini even if $txtAge or $txtSex is empty it should still save IniWrite(@ScriptDir & "\save.ini", $txtName, "Address", $txtAddress) Else ;<-- if all four variables are full then it should save all to the ini IniWrite(@ScriptDir & "\save.ini", $txtName, "Address", $txtAddress) IniWrite(@ScriptDir & "\save.ini", $txtName, "Age", $txtAge) IniWrite(@ScriptDir & "\save.ini", $txtName, "Sex", $txtSex) EndIf Func ERROR_MSG() MsgBox(48, "Error", "Please FILL IN THE BLANKS.") EndFunc Link to comment Share on other sites More sharing options...
jaberwacky Posted May 25, 2010 Share Posted May 25, 2010 (edited) Does this solve the problem? Global $txtName = "name", $txtAddress = "address", $txtAge = "age", $txtSex = "male" If $txtName == "" Or $txtAddress == "" Then ;<-- if these $txtName Or $txtAddress is empty, an error should show ERROR_MSG() ElseIf $txtName <> "" Or $txtAddress <> "" And $txtAge == "" Or $txtSex == "" Then ;<-- if both $txtName and $txtAddress is full save them to the ini even if $txtAge or $txtSex is empty it should still save IniWrite(@ScriptDir & "\save.ini", $txtName, "Address", $txtAddress) Else ;<-- if all four variables are full then it should save all to the ini IniWrite(@ScriptDir & "\save.ini", $txtName, "Address", $txtAddress) IniWrite(@ScriptDir & "\save.ini", $txtName, "Age", $txtAge) IniWrite(@ScriptDir & "\save.ini", $txtName, "Sex", $txtSex) EndIf Func ERROR_MSG() MsgBox(48, "Error", "Please FILL IN THE BLANKS.") EndFunc ;==>ERROR_MSG Edited May 25, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 25, 2010 Share Posted May 25, 2010 (edited) I'm not sure exactly what your 'desired output' is, but I did make some slight additions to your code. Compare the differences. Global $txtName = "name", $txtAddress = "address", $txtAge = "age", $txtSex = "male" If $txtName = "" Or $txtAddress = "" Then ;<-- if these $txtName Or $txtAddress is empty, an error should show ERROR_MSG() ElseIf $txtName > "" Or $txtAddress > "" And $txtAge = "" Or $txtSex = "" Then ;<-- if both $txtName and $txtAddress is full save them to the ini even if $txtAge or $txtSex is empty it should still save IniWrite(@ScriptDir & "\save.ini", $txtName, "Address", $txtAddress) Else ;<-- if all four variables are full then it should save all to the ini IniWrite(@ScriptDir & "\save.ini", $txtName, "Address", $txtAddress) IniWrite(@ScriptDir & "\save.ini", $txtName, "Age", $txtAge) IniWrite(@ScriptDir & "\save.ini", $txtName, "Sex", $txtSex) EndIf Func ERROR_MSG() MsgBox(48, "Error", "Please FILL IN THE BLANKS.") EndFunc edit: slow.. Edited May 25, 2010 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Tiboi Posted May 25, 2010 Author Share Posted May 25, 2010 (edited) Does this solve the problem? Global $txtName = "name", $txtAddress = "address", $txtAge = "age", $txtSex = "male" If $txtName == "" Or $txtAddress == "" Then ;<-- if these $txtName Or $txtAddress is empty, an error should show ERROR_MSG() ElseIf $txtName <> "" Or $txtAddress <> "" And $txtAge == "" Or $txtSex == "" Then ;<-- if both $txtName and $txtAddress is full save them to the ini even if $txtAge or $txtSex is empty it should still save IniWrite(@ScriptDir & "\save.ini", $txtName, "Address", $txtAddress) Else ;<-- if all four variables are full then it should save all to the ini IniWrite(@ScriptDir & "\save.ini", $txtName, "Address", $txtAddress) IniWrite(@ScriptDir & "\save.ini", $txtName, "Age", $txtAge) IniWrite(@ScriptDir & "\save.ini", $txtName, "Sex", $txtSex) EndIf Func ERROR_MSG() MsgBox(48, "Error", "Please FILL IN THE BLANKS.") EndFunc ;==>ERROR_MSG yes it does, how silly of me, spent so much time on this trying to figure the problem. thanks a million bud by the way what does this <> amd == means. write how you pronounce them Edited May 25, 2010 by Tiboi Link to comment Share on other sites More sharing options...
Tiboi Posted May 25, 2010 Author Share Posted May 25, 2010 I'm not sure exactly what your 'desired output' is, but I did make some slight additions to your code. Compare the differences. Global $txtName = "name", $txtAddress = "address", $txtAge = "age", $txtSex = "male" If $txtName = "" Or $txtAddress = "" Then ;<-- if these $txtName Or $txtAddress is empty, an error should show ERROR_MSG() ElseIf $txtName > "" Or $txtAddress > "" And $txtAge = "" Or $txtSex = "" Then ;<-- if both $txtName and $txtAddress is full save them to the ini even if $txtAge or $txtSex is empty it should still save IniWrite(@ScriptDir & "\save.ini", $txtName, "Address", $txtAddress) Else ;<-- if all four variables are full then it should save all to the ini IniWrite(@ScriptDir & "\save.ini", $txtName, "Address", $txtAddress) IniWrite(@ScriptDir & "\save.ini", $txtName, "Age", $txtAge) IniWrite(@ScriptDir & "\save.ini", $txtName, "Sex", $txtSex) EndIf Func ERROR_MSG() MsgBox(48, "Error", "Please FILL IN THE BLANKS.") EndFunc edit: slow.. this works too thanks Link to comment Share on other sites More sharing options...
omikron48 Posted May 25, 2010 Share Posted May 25, 2010 <> is 'not equal'. == is 'equal'. But there's a difference between the equality using = and ==. Don't know what it is though since I always keep using ==. Link to comment Share on other sites More sharing options...
Tiboi Posted May 25, 2010 Author Share Posted May 25, 2010 <> is 'not equal'.== is 'equal'. But there's a difference between the equality using = and ==. Don't know what it is though since I always keep using ==.ok thanks Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 25, 2010 Share Posted May 25, 2010 Language Reference - Operators= Tests if two values are equal. e.g. If $var= 5 Then (true if $var equals 5). Case insensitive when used with strings.== Tests if two strings are equal. Case sensitive. The left and right values are converted to strings if they are not strings already. This operator should only be used for string comparisons that need to be case sensitive. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Tiboi Posted May 25, 2010 Author Share Posted May 25, 2010 Language Reference - Operators thanks for explaining Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 25, 2010 Share Posted May 25, 2010 You bet. Hope it helps. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
omikron48 Posted May 25, 2010 Share Posted May 25, 2010 How about short-circuit evaluation and forced full evaluation of complex boolean statements? Link to comment Share on other sites More sharing options...
jchd Posted May 25, 2010 Share Posted May 25, 2010 The help file shortly explains behavior and the bottom of the Operators page. AutoIt short-circuits false AND primary condition and there is no way to force full eval of OR secondary condition, AFAIK. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 25, 2010 Share Posted May 25, 2010 What about brackets around the OR secondary condition to evaluate it first? - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Tiboi Posted May 25, 2010 Author Share Posted May 25, 2010 i have no idea what you'll are talking about i'm a noob. but for now it works good so its ok Link to comment Share on other sites More sharing options...
omikron48 Posted May 25, 2010 Share Posted May 25, 2010 I just checked the help file, and apparently AutoIt only does the minimal evaluation necessary to get a result from a compound boolean statement.@Tiboi: We're talking about how compound boolean statements are evaluated in AutoIt. A short-circuit evaluation is when a boolean expression stops being evaluated once the result is already determined, so the rest of the boolean expression is no longer evaluated. Link to comment Share on other sites More sharing options...
jchd Posted May 25, 2010 Share Posted May 25, 2010 To answer somdcomputerguy: If (0 = 0 Or ((((trace(1) Or trace(2)))))) Then EndIf If (0 <> 0 Or ((((trace(3) Or trace(4) Or (trace(5) Or trace(6) Or trace(7))))))) Then EndIf Func trace($cond) ConsoleWrite("Condition " & $cond & " was evaluated" & @LF) Return 1 EndFunc Unsignificant parenthesis are ignored, probably because the lexer finds out that in the case at hand, it needs to rely only on precedence and left to right order, and that grouping parenthesis don't matter. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 25, 2010 Share Posted May 25, 2010 Thank you jchd. I've saved your example, and I'll have to run it many more times before I get why it's evaluating the way it is.. But thanks man. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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