Pass Local Variables Between Functions?

Pass Local Variables Between Functions? - Is it possible to pass local variables from one function to another? - Сообщения

#1 Опубликовано: 28.01.2019 18:16:22
justhumm

justhumm

0 сообщений из 18 понравились пользователям.

Группа: 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 Опубликовано: 28.01.2019 18:57:43
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 Опубликовано: 28.01.2019 20:46:02
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: Moderator

Of course it is possible.

variables.sm (19 КиБ) скачан 52 раз(а).

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 Опубликовано: 29.01.2019 21:14:43
justhumm

justhumm

0 сообщений из 18 понравились пользователям.

Группа: 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 КиБ) скачан 40 раз(а).
#5 Опубликовано: 30.01.2019 04:12:49
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 Опубликовано: 30.01.2019 08:06:36
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 30.01.2019 10:18:57
Arie

Arie

93 сообщений из 285 понравились пользователям.

Группа: 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. Файл не найден.Файл не найден.
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#8 Опубликовано: 30.01.2019 13:50:45
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 Опубликовано: 30.01.2019 15:20:10
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 КиБ) скачан 34 раз(а).
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений