Jump to content

neen help with a troublesome script


Recommended Posts

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

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
Link to comment
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..

Edited 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

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
Link to comment
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
Link to comment
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.

Link to comment
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)

Link to comment
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.

Link to comment
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)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...