Local variables, Comments

Local variables, Comments - Сообщения

#1 Опубликовано: 01.08.2013 05:45:47
marcofk

marcofk

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

Группа: User

One more little request: would it be possible to include an option for the line function to keep the variables declared within the line as local? I'm creating calc sheets that use templates from different textbooks, each with their own nomenclature, and I realised that in some cases they use the same variable identifier for different quantities. As I show a screenshot from every source, so that people can check that I'm using the same formulas, there is a risk that a locally defined variable changes the value of the identically named global one. I realise that it's more a matter of choosing your variables carefully, but when you're on page 10 of your calc sheet there is bound to be the odd repetition.

Also, on a separate subject, I wonder if it's possible to include comments (as you would in VBA with the apostrophe or in Python with #) in line with the formulas, so I can have a description of my formulas/statements next to its declaration. Again: I am aware of the description box, but I like to cluster my formulas in line-blocks, and the description only goes at the top. Since SMath uses text special characters to generate the formulas, it shouldn't be a major upgrade to include something like a # to indicate that what follows is a comment... then, again, I'm not Andrey, and it might turn out to be a nightmare :-(

Regards,

Marco
#2 Опубликовано: 01.08.2013 06:07:38
Martin Kraska

Martin Kraska

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

Группа: Moderator

local variables: global and local variables as well as formal paramteres of function declarations are a widely discussed issue in SMath and at least in my opinion not yet settled. I could not yet find out the advantages of name space leakage.

comments: just use string constants on separate lines above the formula you want to comment on (see example by Fridel Selitsky) Then the comments stick to the context, but are not multi-lingual, just as separate text boxes next to the code could be.
comment.PNG
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#3 Опубликовано: 10.09.2013 10:22:13
marcofk

marcofk

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

Группа: User

In principle nobody needs local variables, it suffices to choose your variable names carefully. However, if you have blocks of calcs that are repeated on a calculation sheet, you don't want to risk using global values on a local set of calcs. Also, why not? One of the lamest features of MathCAD proper is that you cannot use names that are allocated to units (e.g. using m for mass, when m is already allocated to meters) as your variable names. Let me repeat: this is an incredibly awful feature that Andrey has already improved upon in SMath. When you are referencing calculations from different sources with different nomenclature on a ten-page calculation sheet, you want to see your inputs locally and you want your formulas to look like they do in the reference. However, if the references use different naming conventions you run the risk of inadvertently changing the value of a global variable that will be used later in the calcs, or you end up with hundreds and hundreds of different variable names and a decreasingly obvious naming convention. In fact, ideally I'd like to be able to paste the screenshot of the reference calcs inside the line, and make it part of the block of calcs/instructions, so I can box it up and make it clear that this is a local set of calcs.
#4 Опубликовано: 10.09.2013 16:46:16
Martin Kraska

Martin Kraska

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

Группа: Moderator

Wrote

One of the lamest features of MathCAD proper is that you cannot use names that are allocated to units (e.g. using m for mass, when m is already allocated to meters) as your variable names.


Meanwhile Mathcad has more than catched up. You even can format the variables (italic) and units (upright) as it is supposed to be by standard. The example is made with (free) Mathcad Prime Express.

mathcad.PNG
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#5 Опубликовано: 12.09.2013 07:20:25
marcofk

marcofk

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

Группа: User

I stand corrected: the version of MathCAD installed on a colleague's machine does not handle variable names matching unit symbols (he was having this very problem a few eeks ago). That's my only source of information about the real MathCAD.
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений