A forum topic for suggesting new features for CastleOS
Script args
Scott Goffman Posts: 111
8/18/2015
|
Scripting feature req: Arguments
I would love to be able to pass arguments when calling a script.
This would mostly be a convenience feature, allowing us to write a single script that can do multiple things (rather than lots of single scripts with duplicate code).
-Scott
|
|
0
link
|
Phil Hawthorne Posts: 400
8/19/2015
|
Hey Scott, I'm not familiar with the way CastleOS or C works specifically, but to reduce code duplication, could you create a global function? Something like: function foo(bar){ if (bar == "one") do this;
if (bar == "two") do that; }
and then in each script, just call the function you need. script one foo(one);
script two foo(two)
|
|
0
link
|
Chris Cicchitelli Administrator Posts: 3390
8/19/2015
|
Scott Goffman wrote: Scripting feature req: Arguments
I would love to be able to pass arguments when calling a script.
This would mostly be a convenience feature, allowing us to write a single script that can do multiple things (rather than lots of single scripts with duplicate code).
-Scott We have this in the system, just not in the GUI. We'll be adding it!
|
|
0
link
|
Chris Cicchitelli Administrator Posts: 3390
8/19/2015
|
Phil Hawthorne wrote: Hey Scott,
I'm not familiar with the way CastleOS or C works specifically, but to reduce code duplication, could you create a global function? Something like:
function foo(bar){ if (bar == "one") do this;
if (bar == "two") do that; }
and then in each script, just call the function you need.
script one
foo(one);
script two
foo(two)
That's true, but only after the script has been run. He's looking for something to send the script at runtime/startup to affect how it starts...
|
|
0
link
|