Hi,

REALbasic 2006r2
Mac OS X 10.4.6

I wanted to adapt the Graphics example to create a triangle to use the Split Function (see below) and "I've got troubles"...

Here's the example from the Language Reference:

Dim Points(6) as Integer
Points(1)=10  //X of Point 1
Points(2)=10  //Y of Point 1
Points(3)=75  //X of Point 2
Points(4)=30  //Y of Point 2
Points(5)=10  //X of Point 3
Points(6)=125 //Y of Point 3
g.ForeColor= RGB(100,200,255)
g.FillPolygon Points


and here's my attempt to modify it:


 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(",")
 // Test #2 (fails too)
 TriOne = Split(TriangleOne,",")

I've got the same error message:

"Error: Type mismatch error. Expected Int32(), but got String()."

Note: this is only a style trouble.


The idea was to write:

Dim Points(6) As Integer
PointsList    = "5,5,25,5,15,25"
Points.Split(PointsList,",")
g.ForeColor   = RGB(100,200,255)
g.FillPolygon   Points

The code is more sexy than the original one, isn't it ?

BTW: Why dim the array using 6 cells ? Also, why filling it starting at cell 1 ?
[at last, I am asking myself why it works...]


[after a simple test]: I can't believe it... it does not works when I dim the array at 5 and fill the cells from 0 to 5... Incredible!

I don't understand :(

Emile

_______________________________________________
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