Sign in to follow this  
Followers 0
Melba23

Array.au3 - Final Beta - Testing required

34 posts in this topic

#1 ·  Posted (edited)

Thread closed

Here is what I hope will be the final Beta version of the new Array.au3. This zip includes the new include file, proposed Help file examples and pages for all new/changed functions:

Please let me know of any bugs, spelling mistakes or other inaccuracies that you can find - I am seeing at least double after a couple of days checking them myself! And I do NOT want any more feature requests - you have had long enough let me know if you wanted any more new additions.

Note: You need the Beta 3.3.11.3 to run this code - it is Beta itself after all. ;)

Current public functions and any changes made:

_ArrayAdd:  Now supports 2D arrays and multiple additions.  Data for addition can be a single value, a delimited string or another array.  The delimiters and the column in which the insertion is to start for 2D arrays can be user-defined.

_ArrayBinarySearch:  Now supports 2D arrays searching in columns.

_ArrayColDelete: New function to delete a column from an array.  Optional to convert to 1D if only 1 column left.

_ArrayColInsert:  New function to insert a column into an array.  Converts 1D to 2D automatically.

_ArrayCombinations: Unchanged

_ArrayConcatenate: Will concatenate 2D arrays with the same number of columns.

_ArrayDelete: Now supports 2D arrays.  Will also delete multiple rows if passed either a range string detailing the rows ("3:7-9:15-25;56") or a 1D array of all the rows to be deleted with a count in the [0] element.

_ArrayDisplay:  Added option to hide the buttons

_ArrayExtract:  New function to return a section of the 1D/2D source array as defined by the user.

_ArrayFindAll: Unchanged

_ArrayInsert: Now supports 2D arrays.  Will also insert multiple rows if passed either a range string detailing the rows ("3:7-9:15-25;56") or a 1D array of all the rows to be inserted with a count in the [0] element. Multiple inserts are made above the specified row of the original array. Data for insertion into 2D arrays can be a single value, a delimited string or another 1D array.  The delimiter and the column in which the insertion is to start can be user-defined.

_ArrayMax: Now supports 2D arrays

_ArrayMaxIndex: Now supports 2D arrays

_ArrayMin: Now supports 2D arrays

_ArrayMinIndex: Now supports 2D arrays

_ArrayPermute: Unchanged

_ArrayPop: Unchanged

_ArrayPush: Unchanged

_ArrayReverse: Unchanged

_ArraySearch: Now supports searching rows as well as columns

_ArraySort: Unchanged

_ArraySwap: Completely rewritten and now swaps entire or part row/columns within the array. SCRIPT BREAKING!!!!!

_ArrayToClip:  Now a simple wrapper for _ArrayToString - so default delimiter is no longer @CR. SCRIPT BREAKING!!!!!

_ArrayToString: Now supports 2D arrays - user-defined delimiters between items and rows.  SCRIPT BREAKING!!!!!

_ArrayTranspose: New and improved jchd code.  Automatically changes from 1D to 2D and vice versa if needed

_ArrayTrim: Now supports 2D arrays

_ArrayUnique: Column number now 0-based not 1-based - this is for consistency with all other array functions. SCRIPT BREAKING!!!!!
Remember that it is YOU who will be using this library in the future - please help make it as bug-free as possible. Over to you! :)

M23

P.S. Do not be surprised if I do not respond immediately to your post even if I am online - I am taking a break from this library for a little while. :geek:

Edited by Melba23
Code removed
1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I've been too busy of late, but one thing caught my attention. It's more a question of choice, but I wonder about the option of concatenating arrays of different numbers of columns, or even different dimensions. The CSVSplit() function I wrote does something similar by adding extra columns as and when needed.

Extract:ed code from _CSVSplit()

$aTemp = StringSplit($aArray[$i], $asDelim[0]) ; Split to get row items
        If Not @error Then
            If $aTemp[0] > $iOverride Then
                $iOverride = $aTemp[0]
                ReDim $aCSV[$iBound][$iOverride] ; Add columns to accomodate more items
            EndIf
        EndIf

;

Although this fixes broken csv files, the downside is that there is no indication of the inconsistant format.

Edited by czardas

Share this post


Link to post
Share on other sites

czardas,

Would that be a feature request by any chance? :whistle:

Look at the _ArrayAdd[2].au3 example - as long as they are both 2D you can already mix and match the size of the dimensions. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites


_ArrayConcatenate: Will concatenate 2D arrays with the same number of columns.

 

--> I would suggest to mention in Helpfile how to use this function (maybe also others) on arrays with Ubound() stored in $array[0] element, for example these arrays returned by StringSplit(). Maybe some liitle example in Helpfile for such situation would be best.

Anyway thank you very much Melba for your hard work on improving UDFs!! :thumbsup:

Share this post


Link to post
Share on other sites

The method used in _ArrayAdd will convert all entries to strings because of the stringsplit function. The original method doesn't have this limitation/bug. I ran into this when I >posted a similar method of using StringSplit for a faster _ArrayAdd function recently. I was told, in no uncertain terms, that it would have never made it into the Array UDF because of this.

Unfortunately _ArrayInsert has the same limitation/bug in it, for the same reason.


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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

BrewManNH,

Thanks very much for that input - a crucial point which I had not considered. :thumbsup:

However, a simple adjustment to _ArrayAdd & _ArrayInsert would allow the conservation of datatypes when passing single items. If passed as an array, datatypes were always conserved, and only if a delimited string were used to pass the values would the datatype be forced to string. Here is an example of an amended _ArrayAdd function:

<snip>

Given that so many AutoIt functions force the return of strings (e.g. any IniRead* function) I personally do not see this as a major limitation - as long as it is explained in the Help file along these lines:

 

"Using a delimited string to pass data to be added forces the content into string format - when passed as a single item or as an array the original datatypes are conserved"

Of course others might disagree - let them speak out. :)

M23

Edited by Melba23
Code removed

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Doesn't that just turn it into _ArrayConcatenate, do we need 2 of them?

1 person likes this

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

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

It looks to me as if combining 1D and 2D arrays with _ArrayAdd() is somewhat problematic.For example - what if I wanted to add a 3D array in the second column at the end of a 2D array?

I am of the opinion that _ArrayAdd() would be better if it were to simply add one value to (possibly any subitem within) a multidimensional array of between 1 and 64 dimensions - 64 being the current limit (actually I believe 63 might be the limit in this case). This action should increase Ubound($aArray, 1) by 1.

If not specified, then the subitem would be automatically set to the first subitem ==> $aArray[$iBound +1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0] etc...

I can think of one practical, and worthwhile, application for this: i.e. adding new ID tags to the first column of a 2D array - the remainder of the row can be populated afterwards. This doesn't imply that there are no other potentially useful applications.

I can't think of any drawbacks arising from this approach - just added functionality within reason.

Edited by czardas

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

BrewManNH,

I knew that being able to assign functions to variables would come in handy one day. :D

How about being able to force the datatype of items passed in a delimited string? Try this code:

<snip>

If people want to add mixed datatypes then they can use an array rather then a string - or write their own function. ;)

As to the requirement for this function and _ArrayConcatenate I have 2 points:

 

- 1. _ArrayConcatenate is limited to arrays of the same basic format (1D to 1D, 2D to 2D with the same number of columns) which seems logical to me. The _ArrayAdd function allows you to join arrays of differing formats, albeit with the limitation of retaining the number of columns of the original array and thus possibly losing some data from the added array.

- 2. I had enough problems when suggesting that we get rid of the original _Array_Swap & _ArrayToClip functions which served no real purpose - I am certainly not going to suggest removing the very useful _ArrayConcatenate! :o

czardas,

I added basic 2D support and enabled different input formats to the function, I did not make it a complete multi-dimensional Swiss Army penknife function. And can I refer you yet again to my comment in the OP about feature requests? Although that one would have been rejected out-of-hand even had you made it earlier - in fact I am not sure I even understand what functionality you are seeking. :P

M23

Edited by Melba23
Code removed

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I'm not thinking of making feature requests if I find myself struggling to discuss or explian my ideas. Adding a new row along with an ID (could be any data type) is an easy and potentially useful feature. Adding a whole row is both complicated and makes for lazy programming. Having array functions that make full use of the bounds within AutoIt is more in line with how I view things. The original _ArrayAdd added a value at the end of an array. My suggestion would not alter the specs.

BTW I don't ever use _ArrayAdd. The suggestion is only for improving the language. However your code is still interesting to me, as is the discussion you are having with BrewmanNH. :)

Edited by czardas

Share this post


Link to post
Share on other sites

Add some array shuffle functions will be nice.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Add some array shuffle functions will be nice.

 

There are two here. Parts of the UDF need updating (I see at least one currently broken function).

Edit

I just realized the above file also requires stringf but you can simply just copy the shuffle functions.

Edited by czardas

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

PincoPanco,

Already thought of that and have some working code (whch also does the datatype forcing trick explained above): ;)

<snip>

How does it look to you? :huh:

M23

Edit: PincoPanco had posted asking about multiple inserts on the same line, honest! :D

Edited by Melba23
Code removed

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

PincoPanco,

Already thought of that and have some working code (whch also does the datatype forcing trick explained above): ;)

<snip>

How does it look to you? :huh:

M23

Edit: PincoPanco had posted asking about multiple inserts on the same line, honest! :D

 

wow, very speedy in answering, :o

I posted a post and removed it  after few seconds because I saw some mistakes on my post, but you had time to see and read it!

(I thought that no one had taken the time to see it in a few seconds, but I was wrong :blink: )

clicking on the "post" button is like stepping into a mousetrap! :D

now I post it again

Edited by Melba23
Code removed from quote

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

despite to what stated in help, using _ArrayInsert() with a wrong range (see example below), you get an odd resulting array and no error (error code 0) is it ok?

also what does the ":" means in this range "3:7-9:15-25;56"?

#include <Array_New.au3>

Global $aArray_Base[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
_ArrayDisplay($aArray_Base, "1D - Original")

; Insert delimited string using range array
$aArray = $aArray_Base
Global $aRange[4] = [3, 3, 3, 3] ; <--- wrong range
Global $sFill = "Insert new line|Insert new line|Insert new line"
_ArrayInsert($aArray, $aRange, $sFill)
ConsoleWrite("Error:"&@error)
_ArrayDisplay($aArray, "1D - Delim String")



P.S (feature request)
it would be useful to be able to insert more consecutive lines (instead of only one) above another with only one command

example: insert 3 lines above 3

original                  new
0                          0
1                          1
2                          2
3                          x new
4                          x new
5                          x new
6                          3
8                          4
                           5
                           6
                           7
                           8

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

BrewManNH,

I knew that being able to assign functions to variables would come in handy one day. :D

How about being able to force the datatype of items passed in a delimited string? Try this code:

<snipped code>

If people want to add mixed datatypes then they can use an array rather then a string - or write their own function. ;)

As to the requirement for this function and _ArrayConcatenate I have 2 points:

 

- 1. _ArrayConcatenate is limited to arrays of the same basic format (1D to 1D, 2D to 2D with the same number of columns) which seems logical to me. The _ArrayAdd function allows you to join arrays of differing formats, albeit with the limitation of retaining the number of columns of the original array and thus possibly losing some data from the added array.

Why do we want to have a standard function that does this? If the arrays aren't the same dimensions as each other it should be an error condition, not create a workaround for poor programming.

_ArrayAdd should be limited to adding items to an array. If you want to concatenate 2 arrays then you should be using _ArrayConcatenate.

 

- 2. I had enough problems when suggesting that we get rid of the original _Array_Swap & _ArrayToClip functions which served no real purpose - I am certainly not going to suggest removing the very useful _ArrayConcatenate! :o[

I wasn't suggesting getting rid of _ArrayConcatenate, I was suggesting getting rid of putting the functionality of it into another function. Edited by BrewManNH

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

Share this post


Link to post
Share on other sites

BrewManNH,

 

Why do we want to have a standard function that does this?

Because it offers the possibility of adding items directly to a specified columns of the array with the other columns being left empty - which I do not see as "poor programming". I found the need to do this for one of mt scripts and wrote a bespoke function - the same functionality based on that code is now in this _ArrayAdd function.

 

I was suggesting getting rid of putting the functionality of it into another function.

As I already explained, the 2 functionalities are not identical, therefore that is not the case.

And do you have any comments on the suggested datatype solution? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

_ArraySum() or _ArrayReplace() , hmm _ArrayInsert might do that already.. is there a flag to overwrite? or does it do that by default..


;Frank. 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0