Underscore in variable name causes "not defined"

Underscore in variable name causes "not defined" - Messages

#1 Posted: 5/15/2010 12:48:22 AM
dg1727

dg1727

0 likes in 18 posts.

Group: User

Hello,

Using a variable name with a space character (which is entered by pressing the _ underscore key), I got an error:



Notice that the tooltip mentions variable "D" instead of "D t". If I remove the space from all instances of the variable name "D t", then P is correctly shown as 3.3333

If I have left more steps in the SMath worksheet than the minimum it takes to show the problem, please bear with me - I based the example on something I was doing for my job.

Here is the .sm file.

Of course, I can keep spaces out of my variable names for now, but maybe something can be changed in future versions of SMath Studio to allow variables to be evaluated that depend on other variables that have spaces in their names.

I wonder if a possible solution would include keeping underscore keypresses as underscore characters in variable names. This is really a separate feature request, but it is related closely enough that I thought it was OK to put in the same forum posting.

Thanks in advance for comment.
#2 Posted: 5/15/2010 6:19:16 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello,
Wrote

I wonder if a possible solution would include keeping underscore keypresses as underscore characters in variable names. This is really a separate feature request, but it is related closely enough that I thought it was OK to put in the same forum posting.


I think that using underscore producing white space should be avoided at the moment. Some other people reported the same thing. However, there are other more exotic characters you can use into a variable name. Underscore as a regular character in the variable name might be useful, but I think there are some restrictions due to the internal SMath working. Andrey might give you a more precise answer.

Regards,
Radovan

EDIT: BTW, see please how the undefined D t variable made a mess into your worksheet:

If the D t variable have had a numerical value before its using, it would not be such a problem:

Also, if you just try to copy D t variable or a part of the region where such a variable exists, you will again make a mess (the characters will be overlapped)
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Posted: 5/15/2010 4:23:14 PM
dg1727

dg1727

0 likes in 18 posts.

Group: User

Wrote

see please how the undefined D t variable made a mess into your worksheet:

If the D t variable have had a numerical value before its using, it would not be such a problem:

Also, if you just try to copy D t variable or a part of the region where such a variable exists, you will again make a mess (the characters will be overlapped)



I made this sample worksheet in an attempt to have multiple scenarios on the same worksheet, as discussed in the hints about user functions section of the Wiki. This requires defining a variable or function before the variables on which it depends ('D_t' in my example, 'a' in the Wiki example) are defined.

So I think the 2 display issues you mention in the quote above may need to be fixed in SMath Studio.
#4 Posted: 6/21/2010 8:57:37 PM
Andrey Ivashov

Andrey Ivashov

2269 likes in 3734 posts.

Group: Super Administrator

Fixed. "_" char can be now used into the math expressions. Fix will be available with a new version of SMath Studio. For now, you can test calculation using SMath Studio Live.

See also Crashes.
#5 Posted: 6/22/2010 4:08:34 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello Andrey,

It seems, "_" will produce a space in the variable name but the underscore in the defined function name.

[LIVE width=282 height=275]http://smath.info/live/?file=1243[/LIVE]

Should it be this way?
On the other hand, I do not know how to copy a region in "Live" mode (I think this is not possible - not sure) in order to see if the underscore would make a mess in the copied math region.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#6 Posted: 6/22/2010 6:53:46 AM
Andrey Ivashov

Andrey Ivashov

2269 likes in 3734 posts.

Group: Super Administrator

Hello.

Wrote

It seems, "_" will produce a space in the variable name but the underscore in the defined function name.
...
Should it be this way?


Good question What do you thing about this? Should the "_" symbol be invisible in variables and functions or not? Fact is that behavior of underscore character should be the same in both cases.

Wrote

On the other hand, I do not know how to copy a region in "Live" mode (I think this is not possible - not sure) in order to see if the underscore would make a mess in the copied math region.


Copying works now too with a latest builds of standalone SMath Studio versions. And you're right - there is no clipboard in Live version yet.

Best regards.
#7 Posted: 6/22/2010 7:10:38 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello Andrey,
Wrote

It seems, "_" will produce a space in the variable name but the underscore in the defined function name.
...
Should it be this way?


Wrote


Good question What do you thing about this? Should the "_" symbol be invisible in variables and functions or not? Fact is that behavior of underscore character should be the same in both cases.


I think the underscore should be visible in either cases. Spaces might make a confusion. We are used to look at spaces as omitted product between two variables. I do not know what other users think.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#8 Posted: 6/22/2010 7:29:13 AM
Andrey Ivashov

Andrey Ivashov

2269 likes in 3734 posts.

Group: Super Administrator

Thanks for the answer. Agree with you. If no one will show the reason of why "_" char should not be displayed I will change it.

Regards.
  • New Posts New Posts
  • No New Posts No New Posts