Home   Help Search Login Register  

Author Topic: array in array = false  (Read 506 times)

0 Members and 1 Guest are viewing this topic.

basil_rs

  • Guest
array in array = false
« on: 24 Feb 2003, 18:49:41 »
maybe iÂ'm to stupid but

globalarray = globalarray + [[[var1,var2,var3]]]

adds a array to a global array so its 2D,

[var1,var2,var3] in globalarray

returns false at all time

globalarray = globalarray + [var1] + [var2] + [var3]

and

var1 in globalarray; var2 in globalarray ; var3 in globalarray

returns true.

why doesnÂ't it work with 2D arrays ?




Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:array in array = false
« Reply #1 on: 24 Feb 2003, 19:03:23 »
As far as I know, you cannot check if an array is within an array using the in command.

However, you can get around it by using the count command.  The following example works if you are using a script.

Code: [Select]
_localarray = [var1,var2,var3]

globalarray = globalarray + _localarray

? "_x in globalarray" count _localarray == count _localarray : True_Code_Here
False_Code_Here

Where you replace the True_Code_Here and False_Code_Here with code to execute depending on if the all values of _localarray are in globalarray.
Ranger

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:array in array = false
« Reply #2 on: 24 Feb 2003, 19:03:39 »
I have no clue, but thats interesting info to know. Did you try giving the array an id before putting into the other array? Like so:


Code: [Select]
~2
globalarray = []
secondarray = [var1,var2,var3]
globalarray = globalarray + [secondarray]
?secondarray in globalarray:hint "Bingo!";exit
hint "Nope!"
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

basil_rs

  • Guest
Re:array in array = false
« Reply #3 on: 24 Feb 2003, 19:09:34 »
array with ID, yup

youÂ're fast here, thanks
 :D  :)

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:array in array = false
« Reply #4 on: 24 Feb 2003, 19:11:32 »
oops. nm.  ;D
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

basil_rs

  • Guest
Re:array in array = false
« Reply #5 on: 24 Feb 2003, 19:20:09 »
i was looking for this shuffle function...
thanx toadlife  ;D