On May 04, 2006, at 15:30 UTC, Emile Schwarz wrote:

>   Dim TriangleOne As Variant // To use the automatic type conversion
>   Dim TriOne(5)   As Integer // 6 entries array
>  
>   // Fills the Variant with a "String variable"
>   TriangleOne = "5,5,25,5,15,25"
>  
>   // Fills the Array
>   // Test #1 (fails)
>   TriOne = TriangleOne.Split(",")

This fails for two reasons.  First, you can't call Split on a variant (and 
there is no need for this to be a variant; you're only storing a string in it, 
so you should declare it as a string).  Second, Split returns an array of 
strings, not an array of integers.

>   // Test #2 (fails too)
>   TriOne = Split(TriangleOne,",")

This one correctly calls Split, but fails for reason two: the result is 
String(), and you're trying to stuff it into Integer(), which is a type 
mismatch.

To split a string and then convert that into an array of integers, you could 
use the SplitToInt function in the StringUtils module:

   TriOne = SplitToInt( TriangleOne, "," )

But even easier might be to simply use the built-in Array function:

  TriOne = Array( 0, 5,5,25,5,15,25 )

Note that I have to insert an extra number (0) because DrawPolygon expects a 
1-based array for odd historical reasons.

Also note, with any of these, that it doesn't matter how big you dimension 
TriOne in its Dim statement; you're going to throw out that array and replace 
it with the result of SplitToInt or Array anyway.  So just declare it as: Dim 
TriOne() as Integer.

Best,
- Joe

--
Joe Strout -- [EMAIL PROTECTED]
Available for custom REALbasic programming or instruction.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to