Jump to content

ReDim: 2 way.


rasim
 Share

Recommended Posts

Hello! First example of array ReDim:

#include <Array.au3>

Dim $aNewArray[1]

For $i = 1 To 2
    $aNewArray[0] += 1
    ReDim $aNewArray[$aNewArray[0] + 1]
    $aNewArray[$aNewArray[0]] = $i
Next
_ArrayDisplay($aNewArray)oÝ÷ Ùj+Ê+­ç-Úw^Å©©æ®¶­sb6æ6ÇVFRfÇC´'&æS2fwC° ¤FÒb33c¶æWt'&³Ð ¤f÷"b33c¶¢ÒFò  b33c¶æWt'&µT&÷VæBb33c¶æWt'&ÒÒ³Ò &TFÒb33c¶æWt'&²T&÷VæBb33c¶æWt'&ҲРb33c¶æWt'&µT&÷VæBb33c¶æWt'&ÒÒÒb33c¶ ¤æW@ ¥ô'&F7Æb33c¶æWt'&

Not work. Where wrong?

Link to comment
Share on other sites

Hi,

Try;

For $i = 1 To 2
    $aNewArray[0]=UBound($aNewArray-1)
    ReDim $aNewArray[UBound($aNewArray) + 1]
    $aNewArray[UBound($aNewArray)-1] = $i
Next
_ArrayDisplay($aNewArray)
Best, Randall
Link to comment
Share on other sites

#include <Array.au3>

Dim $aNewArray[1]

For $j = 1 To 2
    $aNewArray[UBound($aNewArray) - 1] += 1 ;here it $aNewArray[1] not $aNewArray[0]
    ReDim $aNewArray[(UBound($aNewArray) - 1) + 1]
    $aNewArray[UBound($aNewArray) - 1] = $j;here it $aNewArray[1] not $aNewArray[0]
Next

_ArrayDisplay($aNewArray)

Link to comment
Share on other sites

This one work, and sorry for the upper one i thongh i got it so i didn't test it

#include <Array.au3>

Dim $aNewArray[1]

For $j = 1 To 2
    ReDim $aNewArray[UBound($aNewArray) + 1]
    $aNewArray[UBound($aNewArray) - 1] = $j
Next
$aNewArray[0] = UBound($aNewArray) - 1

_ArrayDisplay($aNewArray)oÝ÷ Ù«­¢+Ø¥¹±Õ±ÐíÉÉä¹ÔÌÐì()¥´ÀÌØí9ÝÉÉålÅt()½ÈÀÌØí¨ôÄQ¼È($ÀÌØí9ÝÉÉåmU   ½Õ¹ ÀÌØí9ÝÉÉ䤴ÀÌØí©tôU  ½Õ¹ ÀÌØí9ÝÉÉä¤(%I¥´ÀÌØí9ÝÉÉåmU    ½Õ¹ ÀÌØí9ÝÉÉ䤬Åt($ÀÌØí9ÝÉÉåmU    ½Õ¹ ÀÌØí9ÝÉÉ䤴ÅtôÀÌØí¨)9áÐ(()}ÉÉå¥ÍÁ±ä ÀÌØí9ÝÉÉä¤

The problem with your is UBound($aNewArray) - 1 Doesn't always make 0

Edited by athiwatc
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...