Page 1 of 1 1
Topic Options
#79265 - 2002-10-29 11:06 AM 412.RC1 - Stupid 2d array tricks
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hi all,

seems to be that operations within the new multidim array notation won't work :

(found that one by replacing all "][" with "," in my hearts fragment)

This works :

code:
break on cls

dim $Hands[3]

$Deck = c2,c3,c4,c5,c6,c7,c8,c9,c_10,c___j,c__q,c_k,ca,
d2,d3,d4,d5,d6,d7,d8,d9,d_10,d___j,d__q,d_k,da,
s2,s3,s4,s5,s6,s7,s8,s9,s_10,s___j,s__q,s_k,sa,
x2,x3,x4,x5,x6,x7,x8,x9,x_10,x___j,x__q,x_k,xa

;here is normally a shuffle routine

;excerpt of the Deal routine
$Hands[0] = "","","","","","","","","","","","",""
$Hands[1] = "","","","","","","","","","","","",""
$Hands[2] = "","","","","","","","","","","","",""
$Hands[3] = "","","","","","","","","","","","",""
for $i = 0 to ubound($Deck) step 4
$Hands[1][$i/4] = $Deck[$i]
$Hands[2][$i/4] = $Deck[$i+1]
$Hands[3][$i/4] = $Deck[$i+2]
$Hands[0][$i/4] = $Deck[$i+3]
next

get $

This (new kind of writing it) won't [Eek!] (Script Error: expected ']')

code:
break on cls

dim $Hands[3]

$Deck = c2,c3,c4,c5,c6,c7,c8,c9,c_10,c___j,c__q,c_k,ca,
d2,d3,d4,d5,d6,d7,d8,d9,d_10,d___j,d__q,d_k,da,
s2,s3,s4,s5,s6,s7,s8,s9,s_10,s___j,s__q,s_k,sa,
x2,x3,x4,x5,x6,x7,x8,x9,x_10,x___j,x__q,x_k,xa

;here is normally a shuffle routine

;excerpt of the Deal routine
$Hands[0] = "","","","","","","","","","","","",""
$Hands[1] = "","","","","","","","","","","","",""
$Hands[2] = "","","","","","","","","","","","",""
$Hands[3] = "","","","","","","","","","","","",""
for $i = 0 to ubound($Deck) step 4
$Hands[1,$i/4] = $Deck[$i]
$Hands[2,$i/4] = $Deck[$i+1]
$Hands[3,$i/4] = $Deck[$i+2]
$Hands[0,$i/4] = $Deck[$i+3]
next

get $

Please enlight as I nearly lost my mind in spotting the looney here

Jochen

[ 29. October 2002, 11:08: Message edited by: jpols ]
_________________________



Top
#79266 - 2002-10-29 11:14 AM Re: 412.RC1 - Stupid 2d array tricks
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Got it !

Had to dim $Hands as dim $Hands[3,12] [Embarrassed]
_________________________



Top
#79267 - 2002-10-29 11:27 AM Re: 412.RC1 - Stupid 2d array tricks
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Still doing ubound($Hands[0]) will return array reference out of bounds then [Mad]

Or just referencing one dimension like in
$Hands[1] = Hands_Sort($Hands[1])
will also result in array reference out of bounds

J.

[ 29. October 2002, 11:33: Message edited by: jpols ]
_________________________



Top
#79268 - 2002-10-29 11:42 AM Re: 412.RC1 - Stupid 2d array tricks
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
but:
$Hands[1] = Hands_Sort($Hands[1])

is the error coming from input or output?

I haven't even once needed pure multidim arrays.
as dynamic arrays of arrays are easier to control and you can redim them as much as you want.
_________________________
!

download KiXnet

Top
#79269 - 2002-10-29 11:45 AM Re: 412.RC1 - Stupid 2d array tricks
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Think its input !
_________________________



Top
#79270 - 2002-10-29 11:47 AM Re: 412.RC1 - Stupid 2d array tricks
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
dunno, Like I said, not expert of this new style, but shouldn't you...

well, split the line to:
$Hands[1] =
Hands_Sort(
$Hands[1]
)
_________________________
!

download KiXnet

Top
#79271 - 2002-10-29 11:49 AM Re: 412.RC1 - Stupid 2d array tricks
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
With dynamic arrays of arrays you mean array[n][n] ?
_________________________



Top
#79272 - 2002-10-29 11:52 AM Re: 412.RC1 - Stupid 2d array tricks
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
it does it on the first statement containing the dimension ... as already said it would also fail on a pure ubound($Hands[1]) [Frown]
_________________________



Top
#79273 - 2002-10-30 12:01 AM Re: 412.RC1 - Stupid 2d array tricks
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yes, arrays of arrays [][][][]...
this way every "dimension" can be mixed type array.

I have to hit the road but will be back on this as it is pretty intresting topic.
try to survive.
_________________________
!

download KiXnet

Top
#79274 - 2002-10-30 12:13 AM Re: 412.RC1 - Stupid 2d array tricks
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Just decided to stick wih arrays of arrays (no need to redim other than 1st dimension)

Hopefully Ruud will leave support for that in !!!

Jochen
_________________________



Top
#79275 - 2002-10-30 12:20 AM Re: 412.RC1 - Stupid 2d array tricks
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hahaa.
tried whatever came to mind... like:
$temp=$i / 4
$Hands[1,$temp] = $Deck[$i]

dunno, what is the use if you can't use?
_________________________
!

download KiXnet

Top
#79276 - 2002-10-30 02:12 PM Re: 412.RC1 - Stupid 2d array tricks
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ok,

to put this one back in line :

multidimensional arrays working ok except the fact that one can't obviously reference a single dimension of it :

code:
break on

global $array[3,3]

ubound($array[0])
;or just
$array[0] = sort($array[0])

will result in array reference out of bounds

J.

[ 30. October 2002, 14:13: Message edited by: jpols ]
_________________________



Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.067 seconds in which 0.029 seconds were spent on a total of 12 queries. Zlib compression enabled.