[Gambas-user] How to create Multi-Dimensional string array

MaxVK maximvonk at ...626...
Sun Sep 21 19:51:29 CEST 2008




Kari Laine-2 wrote:
> 
> On Sun, Sep 21, 2008 at 8:16 PM, MaxVK <maximvonk at ...626...> wrote:
> 
>>
>> I am trying to create a multi dimensional array of string, the size of
>> which
>> is not known at design time.
>>
>> Iv spent some time today playing with this, but I cant seem to get it to
>> work at all. I did think that something like: DIM tArray AS
>> String["","",""]
>> would work, but its not right, and I cant work out what to try next.
>>
>> Iv seen some posts about creating a multi dimensional array of integers,
>> but
>> those posts don't seem to help much with strings.
>>
>> Is this possible?
>>
>> Many thanks
>>
>> Max
>>
>> Hi Max,
> 
> hopefully this example will help.
> PUBLIC SUB Button1_Click()
>   DIM i AS Integer
>   DIM j AS Integer
>   DIM k AS Integer
> 
>   DIM MyArray[10, 10, 10] AS String
> 
>   FOR i = 0 TO 9
>     FOR j = 0 TO 9
>       FOR k = 0 TO 9
> 
>         MyArray[i, j, k] = Chr$(i + 65) & " " & Chr$(j + 65) & " " &
> Chr$(k
> + 65)
> 
>       NEXT
>     NEXT
>   NEXT
> 
>   PRINT MyArray[4, 4, 4]
> 
> END
> 
> 
> I am a beginner with Gambas but let me know if you need more help. There
> is
> also a book called something like "a beginners book for gambas" try that
> with Google. It is a PDF about 364 pages. Let me know if you cannot locate
> it.
> 
> Best Regards
> Kari Laine
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 

Thanks Kari, but I still have a problem:

DIM MyArray[10, 10, 10] AS String

explains where I have been going wrong in my thinking, but at the start of
the routine I have no idea what number will be there. So for example, it
might be 10 or it might be 450.

Is there a way that this can be dynamic, in the same was as DIM MyArray AS
String[]

Regards

Max
-- 
View this message in context: http://www.nabble.com/How-to-create-Multi-Dimensional-string-array-tp19596365p19596723.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list