Jump to content

Recommended Posts

Posted

hey, that looks great!

I attach an example of it all working.

For consistency, please see also my simple function which changes "stringsplit" to a zero-based array for easy import at present into your function.

1. On the other hand, I would be keen still for it to be an option so that the array being imported in each line is zero-based or unit based , so that an array made with the ordinary "stringsplit" does not also import an extra row for the previous number of items from the zero index.

2. I wonder whether it is worth reserving row zero, so one can use[0][0] as some sort of code if it is currently a unit based two-dimensional array;

3. and it would then need a function to change from zero-based to single based if a check showed it was zero-based and one-based were requested??...... [and vice versa if that code were not there etc]

4. This would also allow a function for transposing the elements if wished!..... [How far do you want to go!!]

In any case, it looks great.

Thanks, Randall.

5. [PS I still did manage to generate an error if I asked to write to a cell out of range?.... is the error function not complete?]

Posted (edited)

@Randallc

5. [PS I still did manage to generate an error if I asked to write to a cell out of range?.... is the error function not complete?]

Try this $ret = _ArrayCreateTwoDim(2dArray, '*', 3, 20, 20) $ret should be 2 meaning selected row number is bigger than the biggest row on the two dimensional array and @error is set to 2

I see the points 1 - 4 and I'm up to the challange I believe it will be good learning experience. The only problem is that English is my second language and I don't know what do you mean with (zero-based, unit based, sigle base, one base, etc.)

I don't know if you notice I update my preview post and add one more code that will delete the entire 2 dimensional array by adding the word ALL _ArrayCreateTwoDim(2dArray, 'All', 2)

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Posted

Hi @Shibuya,

You can't display Arrays with message mox like that;

I attach your script with a display function from slimShady; or write a loop to a message box if you prefer;

Best, randall

I was just trying if it returns me the correct element

anyway I figured out what where I went wrong

to use _ArrayCreateTwoDim(), the multi-dim array must be declared as 1,1

e.g. $multi-dim[1][1]

not declaring the number of rows n column needed

i think that should have been made clear as a pre-requisite

The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!"

Posted (edited)

Hi,

I take the point about Dim; "_ArrayCreate" for 1D does not use declaration and is

"$ar_NewArray=_ArrayCreate("c","b","c") etc

could we have additional commands to make a UDF; would the following upset the Error management [i don't understand the code here for that....]

Func _ArrayCreate2D( $aRowArray)

local $avArray[1][1]

_ArrayCreateTwoDim($avArray, $aRowArray)

return $avArray

EndFunc

Func _ArrayInsert2D(ByRef $avArray, $aRowArray, $nRow = '')

_ArrayCreateTwoDim($avArray, $aRowArray,1,$nRow)

return @error

EndFunc

Func _ArrayDelete2D(ByRef $avArray, $nRow = '')

_ArrayCreateTwoDim($avArray, "",2,$nRow)

return @error

EndFunc

So we only need [NO Dim function at all ]

$Alphabet=_ArrayCreate2D($varArray1)

_ArrayInsert2D($Alphabet, $varArray2,0)

_ArrayInsert2D($Alphabet, $varArray3,0)

_ArrayDelete2D($avArray, $nRow)

What do you think?

2. You have made your rows "Base 1" - the first item of significance is in element "1", not "0". [in Base 1, the element "zero" may be used, as after "StringSplit", as the "ubound-1" record]

Also , compare an array made by "stringSplit" (the first item of significance is in element "1"), with the same array made by "_ArrayCreate" (the first item of significance is in element "0", and 1 less element as measured by "ubound"),

Additionally, see how my functions work (in posted scripts)

_ArrayToBase1($Array)

_ArrayToBase0($ar_Array)

_StringSplit_0($s_String,$s_Delimiter="|",$i_Flag="0")

I hope this helps clarify it; make your own arrays both ways and compare the data.

3. You don't reallly need option "3" as $Alphabet[1][2]="Changed Cell" already does the job

Best, Randall

Edited by randallc
Posted (edited)

Thanks for the replay, I will check these two functions StringSplit and _ArrayCreate. I will be very busy at work for the next three days so my next replay will be some time on Monday. Oh almost forgot I do like the idea so I will work on fixing _ArrayCreateTwoDim()

$Alphabet=_ArrayCreate2D($varArray1)

_ArrayInsert2D($Alphabet, $varArray2,0)

_ArrayInsert2D($Alphabet, $varArray3,0)

_ArrayDelete2D($avArray, $nRow)

3. You don't reallly need option "3" as $Alphabet[1][2]="Changed Cell" already does the job

Good point I get so involve doing choice 1 and 2 that I didn't think about it.... B) Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

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...