algorithmic modeling for Rhino
Hi,
i made my first VB script in GH:
Private Sub RunScript(ByVal x As List(Of OnCurve), ByVal y As List(Of OnCurve), ByRef A As Object)
Dim arr_CurvesOut, arr_CurvesIn As New List (Of OnCurve)
Dim i As Integer
Dim w As Integer
Dim arrCurvesIn(1) As OnCurve
Dim arrCurvesOut() As OnCurve
For i = 0 To x.Count() - 1
arr_CurvesIn.Clear()
arr_CurvesIn.Add(x(i))
arr_CurvesIn.Add(y(i))
arrCurvesIn(0) = arr_CurvesIn(0)
arrCurvesIn(1) = arr_CurvesIn(1)
w = OnUtil.ON_JoinCurves(arrCurvesIn, arrCurvesOut, 0.001) arr_CurvesOut.Add(arrCurvesOut(0))
Next
A = arr_CurvesOut
End Sub
Everything works good, but I have one warning, which i do not understand. As I suppose, it is related to by val and by ref variables.
"Warning: Variable 'arrCurvesOut' is passed by reference before it has been assigned a value. A null reference exception could result at runtime. (line 94)"
Could somebody explain me, what is wrong in my code?
Thx
Tags:
Hi Lukasz,
this means that arrCurvesOut is declared but not assigned. Vb automatically assigns null (Nothing) to the variable in this case, but this might not have been your intention. If the algorithm works, it's ok to pass Nothing in this case. To make the warning disappear, then just add
Dim arrCurvesOut() As OnCurve = Nothing
or something similar.
- Giulio
_____________
giulio@mcneel.com
McNeel Europe, Barcelona
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by