Sorry to disappoint you, but there is no way (yet) to slice an array.

You can do slicing on strings, with Left, Right and Mid. For example:
Dim str1 As String
Dim str2 As String
str1 = "hello there"
str2 = Mid(str1, 2, 4) ' will point to the same string but with the length
4 and offset 2.
Print str2 ' prints ello

but it is not implemented for arrays.
You can create an own class that wraps an array together with an offset and
length if you want to...

/Emil

2012/10/10 RICHARD WALKER <richard.j.wal...@ntlworld.com>

> Let's say I have a string array with 12 elements. I want to pass some
> of these to a function for processing. What notation do I use to
> specify, say, the "sub-array" comprising elements 6, 7 and 8 of the 12
> element array?
>
> At the moment I can only do it by creating a new array of appropriate
> size and copying the required elements into it. An equally ugly
> alterrnative would be to pass the whole array with a couple of index
> variables to define the limits. Or I could copy the whole array and
> delete the unwanted elements.
>
> I was really hoping that my_array[6 To 12] would work, but not in
> Gambas it seems.
>
> Richard
>
>
> ------------------------------------------------------------------------------
> Don't let slow site performance ruin your business. Deploy New Relic APM
> Deploy New Relic app performance management and know exactly
> what is happening inside your Ruby, Python, PHP, Java, and .NET app
> Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> http://p.sf.net/sfu/newrelic-dev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to