Jump to content

This topic is 4881 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hey all,

i am trying to find out how to get a result from a script - for this test, true / false, but i dont know how.


 

//name of script is recursive add

//script calls self



If [Get (scriptparameter) ≥ 100]

    exit script[]

End If



New Record/ Request

Perform Script ["recursive add"; Paramter: Get (scriptparameter) + 1]

Exit Script [Result: Get(scriptresult)]

 

my goal is to use scripts to test my custom functions but i am trying to figure out recursive scripts & tail recursive scripts . Also how to use the Get (scriptResult) in the correct context.

-ian

Posted

how would this stand in for a recursive call though?


 

Exit Script[ Result: Get ( ScriptResult) ]

 

i guess i just need to write code & test test test huh?

Posted

how to get a result from a script

Use the Get (ScriptResult) function.

my goal is to use scripts to test my custom functions

It 's not necessary to call a script recursively in order to test a recursive algorithm - you can use Loop.

Posted

Comment; I was going based on a mention by JBante -- He gave me some ideas about scripting before writing your custom function. He can better explain what i am trying to do.. Here is an excerpt from a tweet;


In the example from fmforums, I'd do that Perform Script/Exit Script sequence in place of the self-call by the custom function;

 

Next step after a recursive script call might be Exit Script[Result: Get ( ScriptResult )], to stand-in for the recursive function call.

 

** This was from my original question:

 

ques:

 

i am sorry , but i understand coding in an ide from many years ago. NOw you are teaching me something very new, which i would love to learn.



-ian



Os it just a bunch of "set Variable" statements . loops & calculations?            

 

 

ans:

It's mostly Set Variable [] statements. The Case() becomes an If[]/Else If[] series, the Let()s become a series of Set Variable[], the $variables become $$variables, the ~letVariables become $variables, and the recursive custom function calls become recursive script calls followed by something using Get ( ScriptResult ) — Exit Script [Result: Get ( ScriptResult )] in the case of a tail recursive function.            

 

He doesn't explain himself as elaborately as i would like, but he definately has some good ideas or what i think may be good to adopt if you will.

-ian

Posted

And JBante's response to the above :

Not every recursive algorithm can be represented as a loop. A recursive script is a more faithful analog for prototyping a custom function

This topic is 4881 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.