Robdog1955 Posted July 6, 2017 Share Posted July 6, 2017 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. Link to comment Share on other sites More sharing options...
water Posted July 6, 2017 Share Posted July 6, 2017 (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 July 6, 2017 by water Fixed My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Danyfirex Posted July 6, 2017 Share Posted July 6, 2017 @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 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Robdog1955 Posted July 7, 2017 Author Share Posted July 7, 2017 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. Link to comment Share on other sites More sharing options...
Developers Jos Posted July 7, 2017 Developers Share Posted July 7, 2017 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 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Robdog1955 Posted July 8, 2017 Author Share Posted July 8, 2017 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. Link to comment Share on other sites More sharing options...
TheDcoder Posted July 8, 2017 Share Posted July 8, 2017 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! EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
iamtheky Posted July 8, 2017 Share Posted July 8, 2017 *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) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
water Posted July 8, 2017 Share Posted July 8, 2017 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 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Developers Jos Posted July 8, 2017 Developers Share Posted July 8, 2017 (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 July 8, 2017 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Robdog1955 Posted July 8, 2017 Author Share Posted July 8, 2017 Okay, I understand now. Thanks guys for your patience with me!!!!! 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