Pass Local Variables Between Functions?

Pass Local Variables Between Functions? - Is it possible to pass local variables from one function to another? - Messages

#1 Posted: 1/28/2019 6:16:22 PM
justhumm

justhumm

0 likes in 18 posts.

Group: User

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!

[albumimg]1586[/albumimg]
#2 Posted: 1/28/2019 6:57:43 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

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.

Split.PNG
#3 Posted: 1/28/2019 8:46:02 PM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Of course it is possible.

variables.sm (19 KiB) downloaded 50 time(s).

cloud preview
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#4 Posted: 1/29/2019 9:14:43 PM
justhumm

justhumm

0 likes in 18 posts.

Group: User

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

[albumimg]1587[/albumimg]

piecewise - forum1.sm (72 KiB) downloaded 38 time(s).
#5 Posted: 1/30/2019 4:12:49 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

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.
#6 Posted: 1/30/2019 8:06:36 AM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

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.

2019-01-30 12_01_34-Window.png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Posted: 1/30/2019 10:18:57 AM
Arie

Arie

93 likes in 285 posts.

Group: User

Wrote

... 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/forum/yaf_postsm47624_Worst-Case-Analysis-Toolset.aspx#post47624


You 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. File not found.File not found.
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#8 Posted: 1/30/2019 1:50:45 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

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.

CanYou.PNG
#9 Posted: 1/30/2019 3:20:10 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

... I don't understand completely the [H,V]lookup .
Maybe you can use the normal for loop construction.
Maybe otherwise from other modules attached

Utilities Matrix Truth Table [Locate row_col].sm (43 KiB) downloaded 34 time(s).
  • New Posts New Posts
  • No New Posts No New Posts