1 Pages (3 items)
Program loops- one big one or a few smaller ones - Messages
#1 Posted: 11/5/2018 7:55:09 PM
Hi all-
I am trying to build good habits as I learn and grow my SMATH skills- I have a calc sheet with 3 programming loops in it. I realized that I have 2 loops side by side to one, and then there are others ordered as a list under those.
In each of them, I j as my step variable- just because that is how I learned for-then loops ages ago. It occurred to me that I might be setting myself up for trouble as I build and expand things.
Is there 'better' way to organize this? How do you break things like loops to be more human readable?
Can you reuse the loop variables like this? Should each loop have its own variable, or should they all use the same one?
EDIT: Here is a screen shot with the regions and loops I am referring to.
Dennis

I am trying to build good habits as I learn and grow my SMATH skills- I have a calc sheet with 3 programming loops in it. I realized that I have 2 loops side by side to one, and then there are others ordered as a list under those.
In each of them, I j as my step variable- just because that is how I learned for-then loops ages ago. It occurred to me that I might be setting myself up for trouble as I build and expand things.
Is there 'better' way to organize this? How do you break things like loops to be more human readable?
Can you reuse the loop variables like this? Should each loop have its own variable, or should they all use the same one?
EDIT: Here is a screen shot with the regions and loops I am referring to.
Dennis
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#2 Posted: 11/6/2018 12:06:24 AM
WroteCan you reuse the loop variables like this ?
Shoud each loop have its own variable, or shoud they all use the same one ?
On that, answer is not clear cut. In many instances, Smath behave like Mathcad global definition.
Interesting but source of problem. It does not generally evaporate previous use of variables.
The safe way to debug is modular piece-wise construction. In unexplored limits, the right produces
wrong. Smath is superb for detecting errors as long as it is not too far deep embedded.
On the other hand, bear in mind the QA [Quality Assurance], they work piece-wise.
The attached De Casteljau is a good example of chained style construction.
As well, visit Samples for the latest "Draghilev Revisited".
Jean
Spline De Casteljau SVG Companion.sm (98 KiB) downloaded 37 time(s).
#3 Posted: 11/6/2018 11:10:19 AM
WroteHere is a screen shot with the regions and loops I am referring to.
As it looks Dennis, all that invisible stuff is a collection of individual pieces.
X_Y Plot wisely [Lines].sm (12 KiB) downloaded 43 time(s).
1 users liked this post
sergio 11/6/2018 12:13:00 PM
1 Pages (3 items)
-
New Posts
-
No New Posts