Jump to content

Idea for arrays


Recommended Posts

Why not use two arrays? One to hold the data, a second one to hold the meta data? Easy to code, easy to understand, no changes of the current AutoIt functionality needed.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Why not use two arrays? One to hold the data, a second one to hold the meta data? Easy to code, easy to understand, no changes of the current AutoIt functionality needed.

 

This is what I wrote before:

.... without the need to create more space in dimension 2 (Which it is expensive as long the array grows)

 
 
I did pictures that explain why -
Option 1 (as
you suggested):
f1.thumb.png.42791e876e4e6c2be598074afa8
 
Option 2 (as I suggesting):

f2.thumb.png.bc27bb200e7305fa511b619ecc7

 

EDIT:

 
I misunderstood what you suggested.
Use two arrays it the best solution at this time.
But still if you could do what I suggest in the pictures above - it seemed to me better

 

 

Edited by Guest
Link to post
Share on other sites

The solution suggested by water is better than having negative indices - especially if there is some correlation between the positive and (these suggested) negative values of each numeric index.

I did not understand the red part. Can you explain more?

Link to post
Share on other sites

If there were many potential fields, with the amount unknown, and to be added at any point in the future:  I would still go map or dictionary, only because I could call the metadata by what it actually is, rather than have to remember where i put it.

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

Link to post
Share on other sites

I did not understand the red part. Can you explain more?

If $aArray[1] were to have meta data stored in $aArray[-1],  $aArray[2] were to have meta data stored in $aArray[-2],  $aArray[3] were to have meta data stored in $aArray[-3] etc... then there would be a correlation between the positive and (these suggested) negative indices. Perhaps this is not what you are implying, in which case I'm at a loss to understand what you mean.

Edited by czardas
Link to post
Share on other sites

If there were many potential fields, with the amount unknown, and to be added at any point in the future:  I would still go map or dictionary, only because I could call the metadata by what it actually is, rather than have to remember where i put it.

I understand. for "metadata" map seems to be very convenient solution.
But there are few
questions:
a) can I store map in the array ( in [0][0] or [0] ) ?

b)s Is it faster then what I suggested?
 

About "b)" -  my logic says NO.
Why?  Because map itself must to be some kind of "array" but slower..
When the code looks for map.keyabc then what it probably does is something similar to:
_ArraySearch($aArray,'keyabc') -> get memory address -> read the value of "'keyabc'".

That's what I think .. I believe if I'm wrong, then I'm not mistaken too much about this.

On the other hand, in arrays you know the "address"  immediately.

 

... rather than have to remember where i put it.

I understand the downside that you have to remember the address when you keep coding the code..
But you don't really have to remember it.

You can code this way:
 

#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/PE
Global Const $meta_data1 = 0,$meta_data2 = 1,$meta_data3 = 3
Global $aArray[6]
$aArray[$meta_data1] = 'abc'
$aArray[$meta_data2] = 'efg'
$aArray[$meta_data3] = 'hik'
ConsoleWrite($aArray[$meta_data1]&' , '&$aArray[$meta_data2]&' , '&$aArray[$meta_data3] & @CRLF)

 

After you compile it with Au3Stripper (with the /PE ) then the code changes to:
 

Global $aArray[6]
$aArray[0] = 'abc'
$aArray[1] = 'efg'
$aArray[3] = 'hik'
ConsoleWrite($aArray[0]&' , '&$aArray[1]&' , '&$aArray[3] & @CRLF)

 

You don't need to remember that "meta_data1" is always in index 0 and that "meta_data2" is always in 1 and so on..
The fake variables remember it for you.

The same can be with negative indexes of course.

So at the end you write code that
working more efficiently because it never not need search where "keyabc" is stored. It just knows it directly because the preprocessing that done by Au3Stripper

Link to post
Share on other sites

I would not make any of the assumptions you did about speed, and it is absolutely not doing anything similar to an arraysearch when you are calling them in object notation, it IS that value; moreover your penalties are not coming from the datatype as much as they are AutoIt.  It may be preference, and an abuse of KV storage, but it makes it much easier in my head.

 

Edited by iamtheky

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

Link to post
Share on other sites

I'm not sure this kind of functionality belongs in Arrays. For starters it would not be an array anymore. This seems like something you would create as a class in oop, or a structure.

A map is what you would use in AutoIt natively if it were available.

Non natively you could go with iamthekey dictionary, or that class syntax that was posted not so long ago, somewhere where I cannot remember.

You mention unused ram, then what if you have a normal 1D array to use as standard, then every time to add an element, another negative element is added?

That's also unused ram, and with a hell of a lot more people using regular arrays, i don't think it's a great idea.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites

I would not make any of the assumptions you did about speed, and it is absolutely not doing anything similar to an arraysearch when you are calling them in object notation, it IS that value; moreover your penalties are not coming from the datatype as much as they are AutoIt.  It may be preference, and an abuse of KV storage, but it makes it much easier in my head.

 

Yeah, on second thought, I thought I might be wrong about this.
I would love to know how the map
variable working.
Is it more similar to normal variable declaration?

And is Au3Stripper can also strip the names inside the map?
I mean for example: strip $map.keyabc to - $m.k

 

Link to post
Share on other sites

Also, for something like this, it would have to be done internally as suggested you do yourself. ie. starting at a higher non negative element, as though it were 0 and resizing it each time an element is added.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites

If $aArray[1] were to have meta data stored in $aArray[-1],  $aArray[2] were to have meta data stored in $aArray[-2],  $aArray[3] were to have meta data stored in $aArray[-3] etc...

 

No, this is not what i mean.

This will give you the Idea:

f2.thumb.png.b2a9e4337b47bbd3fd188ef431d

But I agree - it's not so necessary feature. it is just a bonus gives you more of what I call "space-order" in one single array (like "space-time" )

I know that this use-case example is very bad.. Please ignore it .. Look just at the ability to do it.

This is just some kind of data organization that I believe can be not bad in some cases.
And this form of data organization is impossible in Autoit.

There are alternatives  to this form of data organization that are good as this (and for this use-case there is match better option)

 

Edited by Guest
Link to post
Share on other sites

If I had such data, I would use a database. AutoIt supports "lite" SQL databases. Easier to understand and easy to code.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

The amount of memory being used in an array shouldn't be much of an issue unless you have huge arrays, or an extremely low memory computer.

You shouldn't have to worry about this memory issue if the rest of the script is written correctly. Also, as suggested, you could always use a database to hold your data, either an in-memory one or a file.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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

    No registered users viewing this page.

×
×
  • Create New...