discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

call module based on parameter value

F
fractorr
Sun, Mar 7, 2021 6:18 PM

Is there way to call a module based on the value of a parameter other than
doing what I have below?  This method works but was wondering if there was a
way to eliminate the callmod module?

--
Sent from: http://forum.openscad.org/

Is there way to call a module based on the value of a parameter other than doing what I have below? This method works but was wondering if there was a way to eliminate the callmod module? -- Sent from: http://forum.openscad.org/
JB
Jordan Brown
Sun, Mar 7, 2021 7:30 PM

On 3/7/2021 10:18 AM, fractorr wrote:

Is there way to call a module based on the value of a parameter other
than doing what I have below?  This method works but was wondering if
there was a way to eliminate the callmod module?

There are any number of other styles for what you're doing, but they all
end up the same:  no, you cannot take a string and have it be
interpreted as a module name.  One way or another, you'll need to
compare that string and explicitly call the desired module.

On 3/7/2021 10:18 AM, fractorr wrote: > Is there way to call a module based on the value of a parameter other > than doing what I have below?  This method works but was wondering if > there was a way to eliminate the callmod module? There are any number of other styles for what you're doing, but they all end up the same:  no, you cannot take a string and have it be interpreted as a module name.  One way or another, you'll need to compare that string and explicitly call the desired module.