Jump to content

[Sovled]how to clipput 2 demensions array?


Recommended Posts

Dim $NextArray[5][2] = [[1, 4, 7, 9, 2],["Why", "not"]]

Anyone there can tell me how to clipput this array please?

And if it possible,

It can Return a delimited string containing all elements within the range specified.

I've tried _ArrayToString ,but err....

If there is a 2 demensions array with no value in some elements,is it OK?

And is there an easy way to reset the array to 0 or empty?

TIA

Edited by kuhasu
Link to comment
Share on other sites

Ok wrote two dimensional array viewer or something:

Dim $NextArray[50][25]
For $a=0 To UBound($NextArray,1)-1
    For $b=0 To UBound($NextArray,2)-1
            $NextArray[$a][$b]=Round(Random(0,1000),0)
    Next
Next
Dim $string
For $i=0 To UBound($NextArray,1)-1
    For $j=0 TO UBound($NextArray,2)-1
        $string&=$NextArray[$i][$j]
        If $j<>Ubound($NextArray,2)-1 Then
            $string&=@TAB&@TAB
        EndIf
        
    Next
    $string&=@CRLF
Next
ClipPut($string)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

...And is there an easy way to reset the array to 0 or empty?...

You can "Dim" it 1.

#include <Array.au3>

Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"
_ArrayDisplay( $avArray, "Whole array" )
Dim $avArray[1]
_ArrayDisplay( $avArray, "Whole array" )
I don' know what to tell you about the ClipPut question - why do you need to do put it into the clipboard?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Sigh....

Dim $NextArray[50][25]

For $a=0 To UBound($NextArray,1)-1

For $b=0 To UBound($NextArray,2)-1

$NextArray[$a][$b]=Round(Random(0,1000),0)

Next

Next

That means I can not

$NextArray[5][2]=0

to simply set all the values......

Oh my,85*72.....

Link to comment
Share on other sites

Sigh....

Dim $NextArray[50][25]

For $a=0 To UBound($NextArray,1)-1

For $b=0 To UBound($NextArray,2)-1

$NextArray[$a][$b]=Round(Random(0,1000),0)

Next

Next

That means I can not

$NextArray[5][2]=0

to simply set all the values......

Oh my,85*72.....

Looping through an array setting the values won't take long, maybe a couple of milliseconds

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Dim $NextArray[5][2] = [[1, 4, 7, 9, 2],["Why", "not"]]

You can declare a 2D with preset set values by providing one row of data in each set of brackets. You declared five rows and 2 columns, so there should be up to five sets of brackets with only two values in each (you can partially fill the array and leave the rest null):

Dim $NextArray[5][2] = [[0, "Zero"], [1, "Odd"], [2, "Even"], [3, "Why"], [4, "not"]]

Calling the first dimension "rows" and the second "columns" is arbitrary, but is also consistent with most common usage.

Anyone there can tell me how to clipput this array please?

I don't think that can be done, and why would you want to?

And if it possible,

It can Return a delimited string containing all elements within the range specified.

I've tried _ArrayToString ,but err....

Post a short demo script of what you tried so we can understand what you want to do.

If there is a 2 demensions array with no value in some elements,is it OK?

Yes, unused elements do not have to be provided a value and remain null.

And is there an easy way to reset the array to 0 or empty?

Zero and empty are not necessarily the same thing, but the easiest way to clear the entire array is to just declare it again in the same scope (Global or Local).

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

monoceres 's code works ,NICE!Thank you!

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,

,,,,,0,0,0,0,0,0,1,0,0,0,0,0,0,0,,

,,,,,0,0,0,0,0,1,1,0,0,0,0,0,0,0,,

,,,,,0,0,0,0,1,1,1,0,0,0,0,0,0,0,,

,,,,,0,0,0,1,1,0,1,1,0,0,0,0,0,0,,

,,,,,0,0,0,1,0,0,0,1,1,0,0,0,0,0,,

,,,,,0,0,0,1,0,0,0,0,1,1,0,0,0,0,,

,,,,,0,0,0,1,0,0,0,0,0,1,0,0,0,0,,

,,,,,0,0,0,1,0,0,0,0,0,1,0,0,0,0,,

,,,,,0,0,0,1,0,0,0,0,0,1,0,0,0,0,,

,,,,,0,0,0,1,0,0,0,0,0,1,0,0,0,0,,

,,,,,0,0,0,1,0,0,0,0,0,1,0,0,0,0,,

,,,,,0,0,0,0,1,0,0,0,1,0,0,0,0,0,,

,,,,,0,0,0,0,1,1,0,1,1,0,0,0,0,0,,

,,,,,0,0,0,0,0,1,1,1,0,0,0,0,0,0,,

,,,,,0,0,0,0,0,0,1,0,0,0,0,0,0,0,,

,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,

,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

,,,,,,,,,,,,,,,,,,,,

And can I let the full things in ONE line?

For the reset things,if I redeclare the array,all values are set to null,right?So I think it's no need to pre set the values now:)

Link to comment
Share on other sites

You can declare a 2D with preset set values by providing one row of data in each set of brackets. You declared five rows and 2 columns, so there should be up to five sets of brackets with only two values in each (you can partially fill the array and leave the rest null):

Dim $NextArray[5][2] = [[0, "Zero"], [1, "Odd"], [2, "Even"], [3, "Why"], [4, "not"]]

Calling the first dimension "rows" and the second "columns" is arbitrary, but is also consistent with most common usage.

I don't think that can be done, and why would you want to?

Post a short demo script of what you tried so we can understand what you want to do.

Yes, unused elements do not have to be provided a value and remain null.

Zero and empty are not necessarily the same thing, but the easiest way to clear the entire array is to just declare it again in the same scope (Global or Local).

:D

To PsaltyDS ,Thank you for your kindly reply!

I just wanna put the whole array in a line with delimiter into textpad.:)

null value can save the resources of my computer,better!*:D*

And to herewasplato,Thank you.

Link to comment
Share on other sites

Check out FileWrite in helpfile :D

OK.I dont wanna trouble u too much,hehe*:D*

I often learn and solve problems by myself,~unless there are some conditions I really can not deal with.

Cheers!Thanks,guys!

Edited by kuhasu
Link to comment
Share on other sites

OK.I dont wanna trouble u too much,hehe* :D *

I often learn and solve the problem by myself,~unless there are some conditions I really can not deal with.

Cheers!Thanks,guys!

That's really a good way of seing things :D

I always think of asking someone as the last resort, I think you learn more by experimenting :)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

...I often learn and solve problems by myself...

...just when I had the spoon ready to feed ya...
$file = FileOpen("output.txt", 2)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

Dim $NextArray[50][25]
For $a = 0 To UBound($NextArray, 1) - 1
    For $b = 0 To UBound($NextArray, 2) - 1
        $NextArray[$a][$b] = Round(Random(0, 1000), 0)
    Next
Next
Dim $string
For $i = 0 To UBound($NextArray, 1) - 1
    For $j = 0 To UBound($NextArray, 2) - 1
        $string &= $NextArray[$i][$j]
        If $j <> UBound($NextArray, 2) - 1 Then
            $string &= @TAB & @TAB
        EndIf
    Next
    FileWriteLine($file, $string)
Next

Run("notepad.exe output.txt")

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
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
 Share

  • Recently Browsing   0 members

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