Grasshopper

algorithmic modeling for Rhino

I use various formulas, repeating in each Private Sub.

Is there any possibility to make them public and call them in private subs?

Views: 384

Replies to This Discussion

Ehm, if I am understanding your question yes.
Inside a single class/module you can access all methods/functions. Accessibility modifiers matter more when you use more classes and assemblies.

Here a simple example. Usually we use Functions to return values, but it is possible to return values using ByRef and Sub's as well.

  Function PlusOne(input As Integer) As Integer
    Return input + 1
  End Function

  Function PlusTwo(input As Integer) As Integer
    Return PlusOne(PlusOne(input))
  End Function

  Function PlusThree(input As Integer) As Integer
    PlusThree = PlusOne(PlusTwo(input)) 'Same as return
  End Function

 

  Private Sub RunScript(ByRef A As Object)
    Dim B As Integer = 2
    Dim C As Integer = PlusTwo(B)
    Dim D As Integer = PlusThree(C)
    A = D
  End Sub

 

What is A ?

 

I hope this helps,

- Giulio
_____________
giulio@mcneel.com
McNeel Europe

Attachments:

Thanks for your reply. It helps a bit in some VB scrip components. I was-ant so explicit. Let's say we have a VBA module in Excel. There you can call a function from any other private subs (at least is how I remember, pardon me if it's wrong). In my case, I have a lot of VB script components, and I don't think I can have only one including all the others. I know that I can make a cluster but once it's created it's a bit hard and time consuming to debug it.

Thank you anyway, it useful.

Oh, I see Stefan.

You can refer to this discussion here:
http://www.grasshopper3d.com/forum/topics/calling-functions-from

This is not as easy as it seems with delegates in Vb.Net or C# because these languages are type-explicit. In Python it's quite easier.

- Giulio
_____________
giulio@mcneel.com
McNeel Europe

Thanks again, I'll try dll files and Phyton.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service