New topic: About multidimensional arrays...
<http://forums.realsoftware.com/viewtopic.php?t=46560> Page 1 of 1 [ 5 posts ] Previous topic | Next topic Author Message BrianOBrien Post subject: About multidimensional arrays...Posted: Mon Jan 14, 2013 2:53 pm Joined: Wed Jul 07, 2010 2:55 pm Posts: 650 Location: University Of Calgary, Faculty Of Medicine i have a send/expect script that looks like sendthis, expectthis thensendthis, thenexpectthat I am trying to save this in an arraydim Script(-1) as Variant Script.Append Array("sendthis", "expecthis") Script.Append Array("thensendthis", "thenexpectthat") But now how do I access the objects in the array? _________________ If at first you don't succeed... Try REALBasic. Top DaveS Post subject: Re: About multidimensional arrays...Posted: Mon Jan 14, 2013 3:40 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4412 Location: San Diego, CA I would look at using the PAIR datatype instead.... dim Script(-1) as PAIR script.append "sendthis":"expecthis" script.append "thensendthis":"thenexpectthat" msgbox script(1).left ' would show "thisendthis" _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top BrianOBrien Post subject: Re: About multidimensional arrays...Posted: Mon Jan 14, 2013 3:54 pm Joined: Wed Jul 07, 2010 2:55 pm Posts: 650 Location: University Of Calgary, Faculty Of Medicine nice. thank you. PAIR is cool... but is it extendable? could there be a Left : middle : right? _________________ If at first you don't succeed... Try REALBasic. Top doofus Post subject: Re: About multidimensional arrays...Posted: Mon Jan 14, 2013 4:41 pm Joined: Thu Sep 10, 2009 2:50 am Posts: 335 Location: Santa Cruz, CA, USA You can't access the items 'inline' because you'd need to cast to an array type which rb doesn't have (yet?). aString = String()(script(5))(1) //? cast script(5) to String() then access 2nd element ? To access you have to first pull the array out dim theStrings() As String = script(5) //implicit variant to String() cast aString = theStrings(1) //access Top DaveS Post subject: Re: About multidimensional arrays...Posted: Mon Jan 14, 2013 4:46 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4412 Location: San Diego, CA you can have a pair where the left or right is another pair but if you are getting to that point... create a class instead dim script(-1) as my_custom_class script.append new my_custom_class("A","B","C","D") of course you need to define what my_custom_class is first _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 5 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
