Jump to content

Recommended Posts

Posted (edited)

i got inspiration from this topic http://www.autoitscript.com/forum/index.php?showtopic=44055..

it's kind of like === operater, if you used javascript, or others you'll know that it compares values not by just if there equal.. but if there the same value type, string, number ect.. maybe autoit developers will implement the === operater, until then you could try this.. suggestions??

ver 2 (4/12/2007)

i changed the number checking, it checks length as well, so 1.0, and 1 should return false... now.

ConsoleWrite(IsIdent(1,1)&@LF); true
ConsoleWrite(IsIdent(false,false)&@LF); true
ConsoleWrite(IsIdent(1,true)&@LF); false
ConsoleWrite(IsIdent(1,'1')&@LF) ; false
ConsoleWrite(IsIdent(true,'true')&@LF) ; false
ConsoleWrite(IsIdent('hello','hellO')&@LF) ; false
ConsoleWrite(IsIdent('Hello','Hello')&@LF) ; true
ConsoleWrite(IsIdent(1, 1.0) & @LF) ;false
ConsoleWrite(IsIdent(default, 'default') & @LF) ;false


Func IsIdent($bVal1, $bVal2)
    If IsString($bVal1) And IsString($bVal2) Then
        If ($bVal1 == $bVal2) Then Return True
        Return False
    ElseIf IsNumber($bVal1) And IsNumber($bVal2) Then
        If ($bVal1 == $bVal1) _
            And StringLen(Binarystring($bVal1)) == _
            StringLen(Binarystring($bVal2)) Then Return True
        Return False
    ElseIf IsKeyWord($bVal1) And IsKeyWord($bVal2) Then
        If ($bVal1 == $bVal2) Then Return True
        Return False
    ElseIf IsBool($bVal1) And IsBool($bVal2) Then
        If ($bVal1 == $bVal2) Then Return True
        Return False
    ElseIf IsBinaryString($bVal1) And IsBinaryString($bVal2) Then
        If ($bVal1 == $bVal2) Then Return True
        Return False
    EndIf
    Return False
EndFunc
oÝ÷ Ú]z»Þ®È¨Ç(uæèÆ÷«Õ«­¢+Ø)
½¹Í½±]ɥѡ%Í%¹Ð İĤµÀí1¤ìÑÉÕ)
½¹Í½±]ɥѡ%Í%¹Ð¡±Í±±Í¤µÀí1¤ìÑÉÕ)
½¹Í½±]ɥѡ%Í%¹Ð ıÑÉÕ¤µÀí1¤ì±Í)
½¹Í½±]ɥѡ%Í%¹Ð İÌäìÄÌä줵Àí1¤ì±Í)
½¹Í½±]ɥѡ%Í%¹Ð¡ÑÉÕ°ÌäíÑÉÕÌä줵Àí1¤ì±Í)
½¹Í½±]ɥѡ%Í%¹Ð Ìäí¡±±¼Ìäì°Ìäí¡±±

Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Posted

Hi,

Nice function...

But with this one not return false :shocked: :

ConsoleWrite(IsIdent(1, 1.0) & @LF)

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

Maybe...

ConsoleWrite(IsIdent(1,1)&@LF); true
ConsoleWrite(IsIdent(false,false)&@LF); true
ConsoleWrite(IsIdent(1,true)&@LF); false
ConsoleWrite(IsIdent(1,'1')&@LF) ; false.... THIS SHOWS TRUE
ConsoleWrite(IsIdent(true,'true')&@LF) ; false
ConsoleWrite(IsIdent('hello','hellO')&@LF) ; false
ConsoleWrite(IsIdent('Hello','Hello')&@LF) ; true


Func IsIdent($bVal1, $bVal2)
    Return $bVal1 == $bVal2
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Posted

  Quote

ConsoleWrite(IsIdent(1,'1')&@LF) ; false.... THIS SHOWS TRUE

Yes, so this is not quite correct checking if given variables is ident.

My example is short, and correct enough to do the job :shocked:

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

ConsoleWrite(_IsIdentic(1, 1) & @LF); true
ConsoleWrite(_IsIdentic(False, False) & @LF); true
ConsoleWrite(_IsIdentic(1, True) & @LF); false
ConsoleWrite(_IsIdentic(1, '1') & @LF) ; false
ConsoleWrite(_IsIdentic(True, 'true') & @LF) ; false
ConsoleWrite(_IsIdentic('hello', 'hellO') & @LF) ; false
ConsoleWrite(_IsIdentic('Hello', 'Hello') & @LF) ; true
ConsoleWrite(_IsIdentic(1, 1.0) & @LF) ;false
ConsoleWrite(_IsIdentic(Default, 'default') & @LF) ;false


Func _IsIdentic($vVariable_A, $vVariable_B)
    If (IsString($vVariable_A) And IsString($vVariable_B)) _
            Or (IsNumber($vVariable_A) And IsNumber($vVariable_B)) _
            Or (IsKeyword($vVariable_A) And IsKeyword($vVariable_B)) _
            Or (IsBool($vVariable_A) And IsBool($vVariable_B)) _
            Or (IsBinaryString($vVariable_A) And IsBinaryString($vVariable_B)) Then
        If ($vVariable_A == $vVariable_B) _
                And (StringLen(BinaryString($vVariable_A)) == StringLen(BinaryString($vVariable_B))) Then Return True
    EndIf
    Return False
EndFunc   ;==>_IsIdentic

a bit smaller :shocked:

Mybe its a silly question but...

what happend to Object, hWnd and Struct ?

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Posted (edited)

Func _IsIdent($vVar1, $vVar2)
    If (IsArray($vVar1) And IsArray($vVar2)) Or _
        (IsKeyword($vVar1) And IsKeyword($vVar2)) Or _
        (IsBool($vVar1) And IsBool($vVar2)) Or _
        (IsBinaryString($vVar1) And IsBinaryString($vVar2)) Or _
        (IsHWnd($vVar1) And IsHWnd($vVar2)) Or _
        (IsNumber($vVar1) And IsNumber($vVar2)) Or _
        (IsObj($vVar1) And IsObj($vVar2)) Or _
        (IsDllStruct($vVar1) And IsDllStruct($vVar2)) Or _
        (IsString($vVar1) And IsString($vVar2)) Then
        If ($vVar1 == $vVar2) And (StringLen(BinaryString($vVar1)) = StringLen(BinaryString($vVar2))) Then Return True
    EndIf
    Return False
EndFunc

I think I'm gonna use this one until (if) the === operator gets added.

*Edit: Double equals between StringLen(BinaryString()) wasn't necessary.

Edited by Saunders

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
  • Recently Browsing   0 members

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