Robdog1955

Help understanding True False

11 posts in this topic

#1 ·  Posted

Can some one explain this bit of code. I thought True was like 1 and False  0. But apparently it is more than that. Here is the code I'm looking at.

If ValidUserPassword($sUsername, $sDomain, $sPassword) == "True" Then Something

Func ValidUserPassword($sUsername, $sDomain, $sPassword)
    Local $bValid = True
    RunAs($sUsername, $sDomain, $sPassword, 2, @ComSpec & " /c  echo test", @SystemDir, @SW_Hide)
    If @Error Then $bValid = False
    Return $bValid
EndFunc
 

How is $bValid equal to a text string?

I want to understand instead of just using the code.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The first statement is wrong. The function returns a binary boolean value (True/False) so you should check for a binary boolean value:

If ValidUserPassword($sUsername, $sDomain, $sPassword) = True Then Something

 

Edited by water
Fixed

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

@water I think the correct terminology is a the function returns a Boolean value.

You can simplify the statement 

 

If ValidUserPassword($sUsername, $sDomain, $sPassword) Then Something

 

Saludos

Share this post


Link to post
Share on other sites

#4 ·  Posted

But it works. If I understand what you are saying, it should not work. That's why I'm asking the question. I can't understand how it could work. I found the code in the forum and thought well if this works, I don't understand what I thought I did. By the way guys thanks for getting back with me so soon. 

Share this post


Link to post
Share on other sites

#5 ·  Posted

Helpfile:

Quote
        Comparison operators (case insensitive if used with strings except for ==)
= Tests if two values are equal. e.g. If $var = 5 Then    (true if $vVar equals 5). Case insensitive when used with strings. See Note below about comparing mixed datatypes.
== 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 if string comparisons need to be case sensitive.

Might give a hint. :)

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted

Yeah, I had looked up the "==" part but did not think a boolean value ie. True or False could be converted into a string. Maybe I do not understand what a boolean value is within the context of AutoIt. I am not a programmer so I hope you will forgive my lack of training. My training comes from you guys and I appreciate you more than you could know. I would be lost without you. That said I would like to especially thank Waters. I have used AD.au3 extensively! But also Melba23, trancexx, UEZ... too many to list...

Anyway, I found that:

MsgBox(0, "Debug", "$bValid = " & $bValid)

Where $bValid is True

yields: $bValid = True

So I guess it is text...

Please correct me if I'm not seeing this correctly.

Share this post


Link to post
Share on other sites

#7 ·  Posted

When you concatenate/append/join something to a "string", the other datatypes (such as Booleans, Integers) are converted to strings as well :)

P.S Boolean is simply a datatype, like integers (numbers). Only 2 values are possible, True or False!


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#8 ·  Posted

*The result is represented as a string, you can still muck around and perform ugly operations while smooshing things together.

$s = "string"
$n = number(5)
$v = $s &- $n
msgbox(0, '' , $v)

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#9 ·  Posted

4 hours ago, Robdog1955 said:

That said I would like to especially thank Waters. I have used AD.au3 extensively!

Glad you like my UDF :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

7 hours ago, Robdog1955 said:

but did not think a boolean value ie. True or False could be converted into a string.

AutoIt3 does things to make it easier and more forgiving ... so in this case:

case VAR_BOOL:
            if (m_bValue)
                _tcscpy(szTemp, _T("True") );
            else
                _tcscpy(szTemp, _T("False") );
            break;

Jos ;)

 

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#11 ·  Posted

Okay, I understand now. Thanks guys for your patience with me!!!!!

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