Jump to content

Recommended Posts

Posted

A quick test...all seems in order.

#AutoIt3Wrapper_Version=B
#AutoIt3Wrapper_Run_Au3Check=N

#include <Array.au3>

; Sleep(1000)

Dim $hTimer = TimerInit()
Local $aArray[10000]
For $i = 1 To 1000000
    UBound($aArray)
Next
ConsoleWrite(TimerDiff($hTimer) & @CRLF)

Local $mInternal[] ; Declare a Map
$mInternal["Internal"] = "AutoIt3" ; Assign an element

Local $mMain[] ; OK
$mMain["Bin"] = $mInternal ;  OK

For $i = 1 To 1000
    MapAppend($mMain, $i) ; OK
Next

ConsoleWrite('IsMap >> ' & IsMap($mInternal) & @CRLF) ; OK
ConsoleWrite('IsMap >> ' & IsMap($mMain["empty"]) & @CRLF) ; OK
ConsoleWrite('IsMap >> ' & IsMap($mMain["Bin"]) & @CRLF) ; OK

ConsoleWrite('MapExists >> ' & MapExists($mMain, "bin") & @CRLF) ; OK
ConsoleWrite('MapExists >> ' & MapExists($mMain, "Bin") & @CRLF) ; OK
ConsoleWrite('MapExists >> ' & MapExists($mMain["Bin"], "Bin") & @CRLF) ; OK
ConsoleWrite('MapExists >> ' & MapExists($mMain["Bin"], "Internal") & @CRLF) ; OK

Local $aMap = MapKeys($mMain)
_ArrayDisplay($aMap)

; MapAppend(), MapExists(), MapKeys() - dot notation versions still available for now.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

HelpFile 3.3.13.6 Issue #2802

Related
(), (), (), (), (), WinWaitDelay (Option), ()

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 7/18/2014 at 1:43 PM, mLipok said:

 

HelpFile 3.3.13.6 Issue #2802

Related
(), (), (), (), (), WinWaitDelay (Option), ()

I broke it and fixed it.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

MapAppend() can be changed to MapPush(), also MapPop() and MapPeek() can be added.

In the following snippet there is no easy way to get value of the last element:

Global $map[]
MapAppend($map, "1")
$map["a"] = "a"
$map["b"] = "b"
MapAppend($map, "2")
MapAppend($map, "3")
$map["c"] = "c"

With MapPush/MapAppend, MapPop, MapPeek, this new type will be a hybrid Stack/Table/Map/AssociativeArray/KeyItemPair/Dictionary/Whatever!

Posted (edited)

Also some new keywords can be added, something like MapEmpty which will be returned by MapPop and MapPeek when the map is empty, and something like MapInvalid when the variable passed to Map* function is not a valid map, and even MapNotFound when a not existing key's value has been requested.

Edited by FaridAgl
Posted
  On 7/18/2014 at 3:04 PM, FaridAgl said:

MapAppend() can be changed to MapPush(), also MapPop() and MapPeek() can be added.

With MapPush/MapAppend, MapPop, MapPeek, this new type will be a hybrid Stack/Table/Map/AssociativeArray/KeyItemPair/Dictionary/Whatever!

 

You could have ordered maps, but you can't have ordered maps AND efficient lookups, and given that lookups is what maps are for, forget about using maps as stacks. Use an array, it's not hard and it would be faster and more appropriate.

  • Moderators
Posted

Jon,

Testing if a non-existent Map value is a Map seems to append the value to the Map:

#AutoIt3Wrapper_Run_Au3Check=N

#include <Array.au3>

Local $mMain[]
Local $mInternal[]

$mMain["Map"] = $mInternal

For $i = 1 To 10
    MapAppend($mMain, $i)
Next

$iRet = IsMap($mMain["Map"])            ; Test if there is a map in an existing key
ConsoleWrite($iRet & @CRLF)             ; There is

$iRet = IsMap($mMain[3])                ; Test if there is a map in an existing key
ConsoleWrite($iRet & @CRLF)             ; There is

$iRet = IsMap($mMain["I_do_not_exist"]) ; Test if there is a map in a non-existent key
ConsoleWrite($iRet & @CRLF)             ; There is not...

Local $aMap = MapKeys($mMain)
_ArrayDisplay($aMap)                    ; ...but look at the last entry <<<<<<<<<<<<<<<<<<
Given my >past record can someone else confirm this please! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

M23,

I guess you meant that second comment of IsMap() to read "; There is not" not "; There is"? But I can confirm there is an issue there with IsMap().

#AutoIt3Wrapper_Run_Au3Check=N

#include <Array.au3>

Local $mMain[]
Local $mInternal[]

$mInternal["Main"] = $mMain

$mMain["Map"] = $mInternal

For $i = 1 To 10
    MapAppend($mMain, $i)
Next

$iRet = IsMap($mMain["Map"]) ; Test if there is a map in an existing key
ConsoleWrite($iRet & @CRLF) ; There is

$iRet = IsMap($mMain[3]) ; Test if there is a map in an existing key
ConsoleWrite($iRet & @CRLF) ; There is not...

$iRet = IsMap($mMain["Map"]["Main"]) ; Test if there is a map in an existing key
ConsoleWrite($iRet & @CRLF) ; There is...

$iRet = IsMap($mMain["I_do_not_exist"]) ; Test if there is a map in a non-existent key
ConsoleWrite($iRet & @CRLF) ; There is not...

Local $aMap = MapKeys($mMain)
_ArrayDisplay($aMap) ; ...but look at the last entry <<<<<<<<<<<<<<<<<<

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

IsMap($vVar) is a sugar for (VarGetType($vVar) = "Map") but indeed it shouldn't cause the creation of a new entry in the map.

$iRet = IsMap($mMain[3]) actually returns 0 (the entry is the integer value 4, hence not a Map) (I just see guinness has a faster keyboard).

You can try my _VarDump function in separate post here to display complex varaible content... and report bugs.

  Reveal hidden contents

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)

Posted

That's fixed it.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Moderators
Posted

Jon,

 

  Quote

See if this fixes the map problem

Fixed. :thumbsup:

  Quote

Lots of significant changes...

Anything in particular you want tested? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

Well they seem to be working well.

#AutoIt3Wrapper_Run_Au3Check=N
#include <MsgBoxConstants.au3>

Local $aArray[2] = [1, "Example"]
Local $dBinary = Binary("0x00204060")
Local $bBoolean = False
Local $hFunc = ConsoleWrite
Local $pPtr = Ptr(-1)
Local $hWnd = WinGetHandle(AutoItWinGetTitle())
Local $iInt = 1
Local $fFloat = 2.1
Local $mMap[]
Local $oObject = ObjCreate("Scripting.Dictionary")
Local $sString = "Some text"
Local $tStruct = DllStructCreate("wchar[256]")
Local $vKeyword = Default

MsgBox($MB_SYSTEMMODAL, "", "Variable Types" & @CRLF & "$aArray is an " & IsArray($aArray) & " variable type." & @CRLF & _
        "$dBinary is a " & IsBinary($dBinary) & " variable type." & @CRLF & _
        "$bBoolean is a " & IsBool($bBoolean) & " variable type." & @CRLF & _
        "$hFunc is a " & IsFunc($hFunc) & " variable type." & @CRLF & _
        "$pPtr is a " & IsPtr($pPtr) & " variable type." & @CRLF & _
        "$hWnd is a " & IsHWnd($hWnd) & " variable type." & @CRLF & _
        "$iInt is an " & IsInt($iInt) & " variable type." & @CRLF & _
        "$fFloat is a " & IsFloat($fFloat) & " variable type." & @CRLF & _
        "$mMap is a " & IsMap($mMap) & " variable type." & @CRLF & _
        "$oObject is a " & IsObj($oObject) & " variable type." & @CRLF & _
        "$sString is a " & IsString($sString) & " variable type." & @CRLF & _
        "$tStruct is a " & IsDllStruct($tStruct) & " variable type." & @CRLF & _
        "$vKeyword is a " & IsKeyword($vKeyword) & " variable type." & @CRLF)

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

Func _AssociativeArray_Startup(ByRef $aArray, $bIsCaseSensitive = False) ; Idea from MilesAhead.
    Local $bReturn = False
    $aArray = ObjCreate('Scripting.Dictionary')
    If IsObj($aArray) Then
        $aArray.CompareMode = ($bIsCaseSensitive ? 0 : 1)
        $bReturn = True
    EndIf
    Return $bReturn
EndFunc   ;==>_AssociativeArray_Startup

; This is broken in the current beta.
Local $hAssoc = 0
_AssociativeArray_Startup($hAssoc)
$hAssoc.Item('TestKey') = 'Test' ; It's added...but doesn't display when you remove the default method.
$hAssoc('TestKey_2') = 'Test_2' ; It's not added when using the default method.
MsgBox(4096, '', $hAssoc('TestKey') & @CRLF)  ; Workaround is to use $hAssoc.Item()
MsgBox(4096, '', $hAssoc.Item('TestKey_2') & @CRLF)
MsgBox(4096, '', $hAssoc.Item('TestKey') & @CRLF) ; OK when using .Item()

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

Local $a[]
Local $b[]
Local $c[]

$a.Val = "a"
$b.Val = "b"
$c.Val = "c"

$a.Next = $b
$b.Next = $c

ConsoleWrite($a.Val & @CRLF)
ConsoleWrite($a.Next.Val & @CRLF)
ConsoleWrite($a.Next.Next.Val & @CRLF)
What's going on here? Why does this not print a, b and c but only a, b?

Also why is ConsoleWrite(($a.Next).Next.Val & @CRLF) allowed, but ConsoleWrite((($a.Next).Next).Val & @CRLF) gives me an error: (14) : ==> Missing right bracket ')' in expression.

Using AutoIt3_MapAppend.exe

Edited by Manadar
Posted

I ran this:

Local $a[]
Local $b[]
Local $c[]

$a.Val = "a"
$b.Val = "b"
$c.Val = "c"
ConsoleWrite(_VarDump($a) & @CRLF)

$a.Next = $b
ConsoleWrite(_VarDump($a) & @CRLF)
$b.Next = $c
ConsoleWrite(_VarDump($b) & @CRLF)

which displays:

Map[1]
      ['Val']          => String       (1) 'a'
Map[2]
      ['Val']          => String       (1) 'a'
      ['Next']         => Map[1]
            ['Val']          => String       (1) 'b'
Map[2]
      ['Val']          => String       (1) 'b'
      ['Next']         => Map[1]
            ['Val']          => String       (1) 'c'

Hope this makes the behavior clearer.

  Reveal hidden contents

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)

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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