Jump to content

Recommended Posts

Posted

I dim'd an array with 26 members, but ArrayDisplay shows 51 (although those I haven't used are 0).

Is this a quirk of ArrayDisplay or did I do something wrong?

I've included code and a snapshot .

Thanks.

#include <guiconstants.au3>
#include <string.au3>
#include <Array.au3>
;use _ArrayInsert to put letters in array...had problems using subscripting

;used to hold the control id of the button of each letter
dim $letter[26]

;used to center window
$centered=-1

;used to place buttons (i.e. letters)
$Xstart=10
$Ystart=10
$Xoffset=50
$Yoffset=35

;used to let us know when to go to the next line
;to place another row of buttons
$count=0

$mywindow=GUICreate("My 1st Window",400,400,$centered,$centered)


;create the alphabet using buttons
;each letter is a button
;use 65-90 and Chr to turn into a Capital Letter for the button
;index starts at 0 so first letter will be A (i.e. 65+0)

For $index=0 to 25
  
  if $count=5 then
;display 5 letters per line
  ;when count = 5, indicates that you need to go to the next line
  ;and start over
  ;so reset xstart and count
;and move to the next line (increase $YStart)   
    $count=0
    $xstart=10
    $Ystart=$YStart+$Yoffset
  endif ;$count=5
   
 ;create the letter button and place it on the child GUI
 ;and put it in the $letter array
 ;increase the $count 
 ;increase $xstart for the next button

  $letter_id=GUICtrlCreateButton (Chr(65+$index),$Xstart+$Xoffset, $Ystart, 50)
  _ArrayInsert ( $letter, $index,$letter_id )
  $count=$count+1
  $xstart=$xstart+$xoffset

Next;$index=0 to 25

_ArrayDisplay( $letter, "_ArrayDisplay() Test" )

GUISetState (@SW_SHOW)
Posted

_ArrayInsert() inserts an element into the array. That means a new element is added at the location and all other elements are moved back. This means everytime its called, the size of the array increases by 1.

Posted

_ArrayInsert() inserts an element into the array.  That means a new element is added at the location and all other elements are moved back.  This means everytime its called, the size of the array increases by 1.

<{POST_SNAPBACK}>

Oh ok...I used it because for some reason I'd get an out of bounds error with array subscripting though I couldn't figure out why.

if you want to take a look

original post: http://www.autoitscript.com/forum/index.ph...489entry52489

Thanks

:idiot:

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