Jump to content

Recommended Posts

Posted

and for the future 

UDF standards for variable name must be expanded for $tbl........

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

What about this??

#AutoIt3Wrapper_Run_Au3Check=N
#AutoIt3Wrapper_Version=B
Global $tblApple[]
$tblApple.Name = "Apple"
$tblApple.Color = "Blue"
$tblApple.Price = 10

Global $tblOrange[]
$tblOrange.Name = "Orange"
$tblOrange.Color = "Green"
$tblOrange.Price = 7

Global $tblBanana[]
$tblBanana.Name = "Banana"
$tblBanana.Color = "Red"
$tblBanana.Price = 13

Global $tblFruits[]
$tblFruits.Apple = $tblApple
$tblFruits.Orange = $tblOrange
$tblFruits.Banana = $tblBanana

ConsoleWrite($tblFruits.Apple.Color & @CRLF)
ConsoleWrite($tblFruits.Apple.Name & @CRLF)
ConsoleWrite($tblFruits.Apple.Price & @CRLF)

ConsoleWrite(@CRLF)

ConsoleWrite($tblFruits.Banana["Color"] & @CRLF)
ConsoleWrite($tblFruits.Banana["Name"] & @CRLF)
ConsoleWrite($tblFruits["Banana"]["Price"] & @CRLF)

ConsoleWrite(@CRLF)

ConsoleWrite($tblFruits.Orange.Color & @CRLF)
ConsoleWrite($tblFruits["Orange"]["Name"] & @CRLF)
ConsoleWrite($tblFruits["Orange"].Price & @CRLF)

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Or how about level 3 (Inception?)

#AutoIt3Wrapper_Run_Au3Check=N
#AutoIt3Wrapper_Version=B
Global $tblApple[]
$tblApple.Name = "Apple"
$tblApple.Color = "Blue"
$tblApple.Price = 10

Global $tblOrange[]
$tblOrange.Name = "Orange"
$tblOrange.Color = "Green"
$tblOrange.Price = 7

Global $tblFruits[]
$tblFruits.Apple = $tblApple

$tblFruits.Apple.Color = $tblOrange
$tblFruits.Apple.Price = $tblApple

ConsoleWrite($tblFruits.Apple.Color.Name & @CRLF)
ConsoleWrite($tblFruits.Apple.Color.Color & @CRLF)
ConsoleWrite($tblFruits.Apple.Color.Price & @CRLF)

ConsoleWrite($tblFruits["Apple"]["Price"]["Name"] & @CRLF)
ConsoleWrite($tblFruits["Apple"]["Price"]["Color"] & @CRLF)
ConsoleWrite($tblFruits["Apple"]["Price"]["Price"] & @CRLF)

This is quite cool, but quite difficult to read at first glance. I will more than likely use it as I would a dictionary structure.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

Hard crash with first assigning a table to an element of an array then assigning back this element to a flat variable:

Local $tbl[]
$tbl.first = "begin"    ; optional to cause a crash

Local $var[3] = [1, $tbl, 3]
Local $x = $var[1]      ; causes a hard crash

Execute(), _ArrayDisplay() and probably others also cause a hard crash, like report below by ripdad says.

Edited by jchd
  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 (edited)

Also (unless I missed something in today's avalanche) and while it's nice to be able to iterate within keys or items, we don't have any way to enumerate both keys and corresponding items, well unless we store keys in a separate array then loop thru items to list both at the same time.

I feel .key() and .item() methods would alleviate the issue.

EDIT: forget it, I missed the announce of .keys(), my bad.

Edited by jchd
  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

#include 'array.au3'

Local $tbl[]
$tbl.first = "begin"    ; optional to cause a crash

Local $var[3] = [1, $tbl, 3]

_ArrayDisplay($var); <-- hard crash

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted

jchd,

Am I mistaken by what you mean?

Local $mTable[]
$mTable["One"] = 1
$mTable["Two"] = 2
$mTable["Three"] = 3

For $sKey In $mTable.Keys()
    ConsoleWrite($sKey & " => " & $mTable[$sKey] & @CRLF)
Next

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Ha, it was .keys()

Thanks

Does the code crash for you as well?

  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 (edited)

.Append works just like Push, what about adding Pop and Peek methods as well?

Then having a .Count method will complete the job ^_^

I already started updating my scripts to use this new feature where possible, feels like power :P

Edited by FaridAgl
Posted (edited)

Assigning a new or existing object to a new or existing table element using dot notation fails with @error = 2

Once correctly created it is nonetheless possible to use dot notation to read it back.

Local $t[]

$t["Whatever"] = ObjCreate("scripting.dictionary")    ; OK
$t.whatever = ObjCreate("scripting.dictionary")        ; failure
If @error Then ConsoleWrite("error = " & @error & @LF)
$t["whatEver"] = ObjCreate("scripting.dictionary")    ; OK
$t.Whatever = ObjCreate("shell.application")        ; failure
If @error Then ConsoleWrite("error = " & @error & @LF)
Local $obj = ObjCreate("shell.application")
$t.WhatEver = $obj                                    ; failure
If @error Then ConsoleWrite("error = " & @error & @LF)

ConsoleWrite("$t.Whatever = " & VarGetType($t.Whatever) & " --> " & ObjName($t.Whatever) & @LF)    ; OK

For $k In $t.keys()
    ConsoleWrite($k & " --> " & VarGetType($t[$k]) & " " & ObjName($t[$k]) & @LF)
Next

AFAICT every other datatype works as expected:

Local $tbl[]
Local $typ3 = [4, 5, 6]
Local $table[]
$table.first = 123

$tbl["String"] = "to be table or not?"
$tbl.string = "to be table or not?"
$tbl["Int32"] = 123456
$tbl.int32 = 123456
$tbl["Int64"] = 123456789012345
$tbl.int64 = 123456789012345
$tbl["Double"] = 3.1415926
$tbl.double = 3.1415926
$tbl["Binary"] = Binary(987654321)
$tbl.binary = Binary(987654321)
$tbl[666] = "Belzebuth"
$tbl["Please_answer_my_question"] = "... waiting!"
$tbl.please_answer_my_question = "... waiting!"
$tbl["Array"] = $typ3
$tbl.array = $typ3
$tbl["Object"] = ObjCreate("shell.application")
$tbl.object = ObjCreate("shell.application")
If @error Then ConsoleWrite("error = " & @error & @LF)
$tbl["Null"] = Null
$tbl.null = Null
$tbl["Default"] = Default
$tbl.default = Default
$tbl["Boolean"] = (1 = 1)
$tbl.boolean = (1 = 1)
$tbl["Function"] = _VarDump
$tbl.function = _VarDump
$tbl["Ptr"] = Ptr(123456789)
$tbl.ptr = Ptr(123456789)
$tbl["Hwnd"] = WinGetHandle("AutoIt Help")
$tbl.hwnd = WinGetHandle("AutoIt Help")
$tbl["Dllstruct"] = DllStructCreate("int;double[2]")
$tbl.dllstruct = DllStructCreate("int;double[2]")
$tbl["Table"] = $table
$tbl.table = $table
Edited by jchd
  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

Sorry for multi-posts, but don't try this (it hangs a core):

;~ $tbl["InitArray"][3] = [7, 8, 9]
;~ $tbl.initarray[3] = [7, 8, 9]
  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)

  • Moderators
Posted (edited)

Jon,

I can reproduce ripdad's crash. It is not _ArrayDisplay failing - it seems you cannot extract a Map from within an array - nor an array or a Map from within a Map:

#AutoIt3Wrapper_Run_AU3Check=n

; Base array
Local $aArray[3] = ["A", "B", "C"]

; Base map
Local $mMap[]
$mMap["first"] = "begin"
ConsoleWrite("Just checking: " & $mMap["first"] & @CRLF & @CRLF)

; Add both to container array
Local $aContainer_Array[4] = [0, $aArray, $mMap, 3]

; Add both to container Map
Local $mContainer_Map[]
$mMap["Map"] = $mMap
$mMap["Array"] = $aArray

; Extract array from container array
ConsoleWrite("Extracting array from array" & @CRLF)
$vTmp = $aContainer_Array[1]
ConsoleWrite("Array extracted" & @CRLF)
ConsoleWrite("Array read: " & $vTmp[0] & @CRLF & @CRLF) ; This works

; Extract array from container map
ConsoleWrite("Extracting array from Map" & @CRLF)
$vTmp = $mContainer_Map["Array"]
ConsoleWrite("Array extracted" & @CRLF)
If IsArray($vTmp) Then
    ConsoleWrite("Array read: " & $vTmp[0] & @CRLF & @CRLF)
Else
    ConsoleWrite("But cannot be read" & @CRLF & @CRLF) ; But not this...
EndIf

ConsoleWrite("Extracting Map from Map" & @CRLF)
$vTmp = $mContainer_Map["Map"]
ConsoleWrite("Map extracted" & @CRLF)
If IsTable($vTmp) Then
    ConsoleWrite("Map read: " & $vTmp["first"] & @CRLF & @CRLF)
Else
    ConsoleWrite("But cannot be read" & @CRLF & @CRLF) ; ...not this
EndIf


ConsoleWrite("Extracting Map from array" & @CRLF)
$vTmp = $aContainer_Array[2]                               ; And this crashes <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
ConsoleWrite("Map extracted" & @CRLF)
ConsoleWrite("Map read: " & $vTmp["first"] & @CRLF & @CRLF
Can others please check the code and confirm their results. :)

M23

Edited by Melba23
Expanded code

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

Jon, I hope this bug reports don't disappoint you. Yes, this table type has some bugs and needs some extra works to be stable, but honestly, it's good enough even right now.

Thanks for the time you put on this, I understand that you won't get anything in return, so, thanks a lot.

  • Administrators
Posted

  On 7/16/2014 at 1:02 AM, FaridAgl said:

I already started updating my scripts to use this new feature where possible, feels like power :P

Not a great idea, it may change syntax a lot...

  On 7/16/2014 at 11:55 AM, FaridAgl said:

Jon, I hope this bug reports don't disappoint you. Yes, this table type has some bugs and needs some extra works to be stable, but honestly, it's good enough even right now.

Thanks for the time you put on this, I understand that you won't get anything in return, so, thanks a lot.

Trancexx did most of the initial work ages ago. But I have just spent the last week recoding it and trying to get it working like I wanted (and no doubt nothing like she wanted). I'm not sure I've succeeded yet. 

Posted

Seems like there is a little problem in Table type and Static declaration:
 

Foo()
Foo()
Foo()

Func Foo()
    Local Static $i = 0
    $i += 1

    Local Static $tblTest[]
    MsgBox(0, $i & "st call", $tblTest.Bar) ;It must be blank only in the first call to Foo()

    $tblTest.Bar = "Hello world!"
    ;MsgBox(0, $i & "st call", $tblTest.Bar) ;Check to make sure "Hello world!" is assinged to $tblTest.Bar
EndFunc
  • Administrators
Posted

  On 7/16/2014 at 5:49 AM, Melba23 said:

Jon,

I can reproduce ripdad's crash. It is not _ArrayDisplay failing - it seems you cannot extract a Map from within an array - nor an array or a Map from within a Map:

 

There's a bug in your code:

; Add both to container Map
Local $mContainer_Map[]
$mMap["Map"] = $mMap
$mMap["Array"] = $aArray

should be:

; Add both to container Map
Local $mContainer_Map[]
$mContainer_Map["Map"] = $mMap
$mContainer_Map["Array"] = $aArray

I've fixed the hard crash. :)

  • Moderators
Posted

Jon,

Apologies for that. :>

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

 

  • Administrators
Posted
  On 7/16/2014 at 3:12 AM, jchd said:

 

Assigning a new or existing object to a new or existing table element using dot notation fails with @error = 2

Once correctly created it is nonetheless possible to use dot notation to read it back.

Fixed.

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

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