discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

function return values

LB
L Boyd
Wed, Nov 18, 2015 5:14 PM

From the thread "Special variables"

whburling wrote

I am uncertain if functions can be written exactly as modules with the
ability to return a value unrelated to any passed parameter or any special
variable.  I am finding out that I do not understand how to "return" an
arbitrary value.

User defined functions can return just about anything

var=" regular variable ";
$v =" special variable ";

function junk(input=13) = ["this is a test function which returns
",var,$v,[input],[1,2,3,4],[2:6]];
echo(junk());
ECHO: ["this is a test function which returns ", " regular variable ", "
special variable ", [13], [1, 2, 3, 4], [2 : 1 : 6]]

For more see  OpenSCAD_User_Manual/User-Defined_Functions_and_Modules
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/User-Defined_Functions_and_Modules
which was recently updated.

--
View this message in context: http://forum.openscad.org/function-return-values-tp14624.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

>From the thread "Special variables" whburling wrote > I am uncertain if functions can be written exactly as modules with the > ability to return a value unrelated to any passed parameter or any special > variable. I am finding out that I do not understand how to "return" an > arbitrary value. User defined functions can return just about anything var=" regular variable "; $v =" special variable "; function junk(input=13) = ["this is a test function which returns ",var,$v,[input],[1,2,3,4],[2:6]]; echo(junk()); ECHO: ["this is a test function which returns ", " regular variable ", " special variable ", [13], [1, 2, 3, 4], [2 : 1 : 6]] For more see OpenSCAD_User_Manual/User-Defined_Functions_and_Modules <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/User-Defined_Functions_and_Modules> which was recently updated. -- View this message in context: http://forum.openscad.org/function-return-values-tp14624.html Sent from the OpenSCAD mailing list archive at Nabble.com.