Jump to content

I'm still really confused.


ratacat
 Share

Recommended Posts

I know someone was kind enough to write a nice piece of code a few pages back to try and help me understand how to use bi-dimensional arrays. I've spent about an hour tinkering with it, and I wasn't able to learn anything about practical application I guess. I've been using a lot of scripting with poker cards, if anyone could write a little piece that stores card suit, card number(1-9, t, j, q, k, a), and like two sets of three digit number per card I would love to inspect it. Or if anyone feels they have the ability to write a small program that shows the practicality of a bidimensional array I'd be thrilled. Sorry to bug everyone, just these things aren't quite clicking.

Link to comment
Share on other sites

Here is some code for a TRI-dimensional array. This is from a closed source project so your lucky...

$Main = GUICreate('Bounce /export', 300, 700, -1, -1, 0x00280000, 0x00000080)
    Global Const $Number = IniRead('levels.ini', '_GLOBAL_', 'LEVEL_NUMBER', 0)
    If $Number = 0 Then
        MsgBox(0, '', 'No levels found')
        Exit
    EndIf
    Dim $Levels[$Number + 1][7][3]
    For $Count = 1 To $Number
        $Levels[$Count][0][0] = IniRead('levels.ini', '_GLOBAL_', 'Level_' & String($Count), '')
        $Levels[$Count][0][1] = GUICtrlCreateCheckbox(String($Count) & ' - ' & $Levels[$Count][0][0], 5, ( ($Count - 1) * 30) + 5, 260, 25)
    Next
    MsgBox(0, 'Bounce /export', 'After choosing, close window to finish exporting')
    GUISetState()
    Do
        $msg = GUIGetMsg()
        Sleep(1)
    Until $msg = $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE)
    Dim $Line, $Progress = 0
    $Levels[0][0][0] = $Number
    For $Count = 1 To $Number
        $Temp = GUICtrlRead($Levels[$Count][0][1])
        If $Temp = 1 Then
            $Levels[$Count][0][2] = 1
            For $CountA = 1 To 6
                $Levels[$Count][$CountA][1] = IniRead('levels.ini', 'Level_' & $Levels[$Count][0][0], 'Box_Strength_' & String($CountA), 1)
                $Levels[$Count][$CountA][0] = IniRead('levels.ini', 'Level_' & $Levels[$Count][0][0], 'Picture_Type_' & String($CountA), '')
            Next
            $Levels[$Count][0][3] = IniRead('levels.ini', 'Level_' & $Levels[$Count][0][0], 'Bumper_File', '')
        Else
            $Levels[$Count][0][2] = 0
            $Levels[0][0][0] = $Levels[0][0][0] - 1
        EndIf
    Next

Also, here is the one you wanted with the poker cards:

Dim $Array[53][2]
$Array[0][0] = 0
For $Count = 1 To 4
    For $Count_B = 1 To 13
        $Array[0][0] = $Array[0][0] + 1
        If $Count_B > 10 Then
            If $Count_B = 11 Then $Array[$Array[0][0]][0] = 'Jack'
            If $Count_B = 12 Then $Array[$Array[0][0]][0] = 'Queen'
            If $Count_B = 13 Then $Array[$Array[0][0]][0] = 'King'
        Else
            $Array[$Array[0][0]][0] = $Count_B
        EndIf
        If $Count = 1 Then 
            $Array[$Array[0][0]][1] = 'Spade'
        ElseIf $Count = 2 Then 
            $Array[$Array[0][0]][1] = 'Club'
        ElseIf $Count = 3 Then 
            $Array[$Array[0][0]][1] = 'Heart'
        Else 
            $Array[$Array[0][0]][1] = 'Diamond'
        EndIf
    Next
Next

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Link to comment
Share on other sites

that first one you gave WOlvereness was way over my head. I just started this like three days ago(thats no excuse). But that second one with the poker cards I think I can understand, give me a few minutes to print those arrays out and see how they look when sent to notepad. Thankyou everyone for all the patience and help...btw I was looking forward to that children's toy one but link didn't work....stupid IE.

Link to comment
Share on other sites

Here's the example:

; Example 4 (a two dimension array)
MsgBox(4096, "Two Dimension Array", "Press OK for a Two Dimension Array.")
; Dimension the array (over sized on purpose)
Dim $asEveryBodyToys[3][20]
; Put the items for person 1 (Mary) into the array
$aToys = StringSplit("Mary,Doll,Tea Set,Jacks,Radio,Puzzles", ",")
$asEveryBodyToys[0][0] = $aToys[1]
For $i = 1 to $aToys[0]
   $asEveryBodyToys[0][$i - 1] = $aToys[$i]
Next
; Put the items for person 2 (Joe) into the array
$aToys  = StringSplit("Joe,Drum,Bike,Train,Blocks,Cars", ",")
$asEveryBodyToys[1][0] = $aToys[1]
For $i = 1 to $aToys[0]
   $asEveryBodyToys[1][$i - 1] = $aToys[$i]
Next
; Display each item in the array for each person (index 2 is empty)
For $i = 0 to UBound($asEveryBodyToys) - 1
   MsgBox(4096, $asEveryBodyToys[$i][0], $asEveryBodyToys[$i][1] & @lf & $asEveryBodyToys[$i][2] & @lf & $asEveryBodyToys[$i][3] & @lf & $asEveryBodyToys[$i][4] & @lf & $asEveryBodyToys[$i][5])
Next
Link to comment
Share on other sites

thanks for code Slim, I am about to go study that and see what I can get from it. As for the card one Wolverener it has helped a lot...I edited it to print out how each card of each suit into Notepad, as well as added in support for aces. But I had some serious questions about the aces...heh it was accidental and now I am not sure WHY it works. I will add in notes to label where the questions are.

Dim $Array[53][2]
$Array[0][0] = 0

For $Count = 1 To 4
    For $Count_B = 1 To 13
        $Array[0][0] = $Array[0][0] + 1
        If $Count_B = 1 then $Array[$Array[0][0]][0] = 'Ace';*****LINE 1 
        If $Count_B > 10 Then
            If $Count_B = 11 Then $Array[$Array[0][0]][0] = 'Jack'
            If $Count_B = 12 Then $Array[$Array[0][0]][0] = 'Queen'
            If $Count_B = 13 Then $Array[$Array[0][0]][0] = 'King'
        Elseif $Count_B = 1 then $Array[$Array[0][0]][0] = 'Ace';********Line 2  
        Else
            $Array[$Array[0][0]][0] = $Count_B
        EndIf
        If $Count = 1 Then 
            $Array[$Array[0][0]][1] = 'Spade'
        ElseIf $Count = 2 Then 
            $Array[$Array[0][0]][1] = 'Club'
        ElseIf $Count = 3 Then 
            $Array[$Array[0][0]][1] = 'Heart'
        Else 
            $Array[$Array[0][0]][1] = 'Diamond'
        EndIf
    Next
Next

run("notepad.exe")
sleep(500)
for $a = 1 to 52
    for $b = 0 to 1
        send($Array[$a][$b])
    next
    send(@cr)
next

Run that first as is and see what happens...that was my ideal goal.

but try removing EITHER line one or line two in question and look what happens. It was an accident that I had them both in there at the same time to begin with, I meant to take out line 1 before I tried line two. again thanks for all the support, I am starting to get these, I'm going to go tinker with that children's toys one now. /cheers Slim

Link to comment
Share on other sites

that first one you gave WOlvereness was way over my head. I just started this like three days ago(thats no excuse).  But that second one with the poker cards I think I can understand, give me a few minutes to print those arrays out and see how they look when sent to notepad. Thankyou everyone for all the patience and help...btw I was looking forward to that children's toy one but link didn't work....stupid IE.

<{POST_SNAPBACK}>

I must have screwed up the link. Just do a forum search for "doll drum train", without the quotes. In the results, look for post #51983 (by me).

Phillip

Link to comment
Share on other sites

I must have screwed up the link.  Just do a forum search for "doll drum train", without the quotes.  In the results, look for post #51983 (by me).

<{POST_SNAPBACK}>

http://http:// doesn't help the link... Take off the first http://

Also, Line #2 is better because if you do line A then after the checking > 10, it will write over the Ace unless yhou say 'If not = 1'

Edited by Wolvereness

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

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