SMath Studio Forum
»
SMath Studio
»
Questions
»
Pass Local Variables Between Functions?
Rank: Member Groups: Registered
Joined: 02/03/2016(UTC) Posts: 18
|
I don't think this is possible, but I figured I would ask... When dealing with long, multi-page function definitions, is it possible to break a function in multiple "sub-fuctions" (that will each fit on one page)? ...Is there some way to pass multiple local variables from one function to another? Thanks!
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: justhumm When dealing with long, multi-page function definitions, is it possible to break a function in multiple "sub-fuctions" (that will each fit on one page)?
...Is there some way to pass multiple local variables from one function to another? Can't see how to relate your matrix to the the double question: split/pass. You can do whatever you need whether from source or from work sheet result. Too vague questions are hard to doctor w/o work sheet.
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
|
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Member Groups: Registered
Joined: 02/03/2016(UTC) Posts: 18
|
Thanks for the responses, but I still thinking that I what I was hoping (not expecting) to achieve is not possible. I am just working with some data table (matrix) calculation and manipulation. And, though simple, the functions / routines that I have come up with are rather long and can extend over the page breaks, which is making portions of them difficult or impossible to see. My hope was that if I could break the longer function into a few smaller functions, then I could control the page break locations, as well as make the local equations more user-friendly (for checking) by having the local variables (and their values) pass from one embedded function to the next. But I don't think the local variables will pass between the functions that way. :*( function3 (x) = function2 (function1 (x)) Off_b = Off_a (names (table1, table2, value)) in the attached worksheet piecewise - forum1.sm (73kb) downloaded 11 time(s).
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Can't you just input/process the maths ? At the very end plug the header and insert that bloody col [very easy]. That ease debugging wrt syntax is incorrect.
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
If in your worksheet you have to input the table once, move the data grouping outside the function on the canvas and everything will be available for any function. However anything defined at some point is available at the same level and on deeper levels, thus you can make all more compact/readable by calling one or more functions after defining you data. Edited by user 30 January 2019 14:15:00(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/03/2016(UTC) Posts: 276 Was thanked: 91 time(s) in 57 post(s)
|
Originally Posted by: justhumm ... My hope was that if I could break the longer function into a few smaller functions, then I could control the page break locations, as well as make the local equations more user-friendly (for checking) by having the local variables (and their values) pass from one embedded function to the next.
But I don't think the local variables will pass between the functions that way. :*(.... I believe you can do this, but you have to pass the function and their parameters in seperately. I do this for my Worst Case Analysis tool set I created which you can find here: https://en.smath.com/for...s-Toolset.aspx#post47624You do have to be careful of how you define the function and it's inputs, but it works. Attached is a simple example as well using pythagorean theorem. pythagorean.sm (7kb) downloaded 10 time(s).Edited by user 30 January 2019 16:27:32(UTC)
| Reason: Not specified |
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: justhumm I am just working with some data table (matrix) calculation and manipulation. And, though simple, the functions / routines that I have come up with are rather long and can extend over the page breaks, which is making portions of them difficult or impossible to see.
My hope was that if I could break the longer function into a few smaller functions, then I could control the page break locations, as well as make the local equations more user-friendly (for checking) by having the local variables (and their values) pass from one embedded function to the next.
But I don't think the local variables will pass between the functions that way. I get lost between your request and the work sheet. The way you do, you create the system you process further. Just process the simple creation. once done, easy to restore the header and rows "identity". We have the modules from Matrix Treasury. Just finish the maths, post and will do. Those data you have entered, if they come from simple unique design: fine. If they come from immense data base, per say from like a National Standard, some more involved tools are needed, just to be adapted. What page length have to do in there ? Use separators per piece maths.
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
|
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
Pass Local Variables Between Functions?
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.