Sign in to follow this  
Followers 0
Tiboi

neen help with a troublesome script

17 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by jaberwocky6669

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Tiboi

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

<> 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 ==.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

You bet. Hope it helps.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

How about short-circuit evaluation and forced full evaluation of complex boolean statements?

Share this post


Link to post
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

i have no idea what you'll are talking about i'm a noob. but for now it works good so its ok

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

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.

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