HP Forums

Full Version: HP Prime : Programming and the Comma
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hi,

I had this little annoyance about programming with the Prime and using Comma as decimal mark. I am used to it and in many countries that is the current decimal separator. All it takes is to put two instructions separated by ";" to have a "Syntax error in program line..." message. So, when comma is set, the calculator find a syntax error after a semi-colon between instructions.

Something as simple as :

EXPORT ONE()
BEGIN
local x;
x:=1;
msgbox(x);
END;

produces a syntax error at the beginning of line 4.

Of course, once a program is compiled without errors, it can run whatever the decimal separator is set. Before debugging and making changes to a program, I go to home setting and change this option and when everything is fine and the program compiles, I return and change it again. A little annoying but feasible.

What I would like to ask, because I did not find anything about it in the manual, is: when comma is the decimal mark, is there other character to be use to finish an instruction that is not the semicolon?

Thanks and regards,

Miguel

Well, the error must be due to something else. Out of curiosity, I wrote the following in my HP Prime (note the capital letters)

EXPORT ONE()
BEGIN
LOCAL X;
X:=1;
MSGBOX(X);
END;

It runs ok!

Hi,

No, same problem. Could you please try this (I am using the emulator and the program name is ONE or whatever you like):


[Shift]-[Settings]-Decimal Mark: Comma(,)

[Shift]-[Program]-choose "ONE"-[Edit]-[Check]

I get "Error: Syntax Error" every time.

Thanks,

Miguel

Oh, yes, I do get an error with

Decimal Mark: Comma(,)

Quote:
Hi,

I had this little annoyance about programming with the Prime and using Comma as decimal mark. I am used to it and in many countries that is the current decimal separator. All it takes is to put two instructions separated by ";" to have a "Syntax error in program line..." message. So, when comma is set, the calculator find a syntax error after a semi-colon between instructions.

Something as simple as :

EXPORT ONE()
BEGIN
local x;
x:=1;
msgbox(x);
END;

produces a syntax error at the beginning of line 4.

Of course, once a program is compiled without errors, it can run whatever the decimal separator is set. Before debugging and making changes to a program, I go to home setting and change this option and when everything is fine and the program compiles, I return and change it again. A little annoying but feasible.

What I would like to ask, because I did not find anything about it in the manual, is: when comma is the decimal mark, is there other character to be use to finish an instruction that is not the semicolon?

Thanks and regards,

Miguel


It appears the issue is that in comma mode:

"." ==> "," (period is now comma)

"," ==> ";" (comma is now semi-colon)

But ";" is left as-is. So in programs comma(,) mode on,

begin
local x;
x:=1;
msgbox(x);
end;

is likely being interpreted as

begin
local x,x:=1,msgbox(x),end,

in dot(.) mode.

Out of curiosity, is the colon (:) by itself used for anything? Or do many non-USA countries use the semicolon (;) like a comma (,)?

Well, in Spanish:

";" is used to indicated a longer pause than ","

":" is generally used to give an explanation about something or to enumerate a list of things.

The best way to deal with the issue would be to force dot mode in the program editor. I'm not aware of a programming language that is dependent on such an environment setting.

When such a program is run, it should obey to the rules set by the user. There might be a problem with EXPR() or CAS() where a string is parsed as an expression. The decoder should obey the current user settings then.

Hi Marcus,

That is what I thought it would do (obey to the rules set by the user), but that is not the case. As I stated, I found a workaround setting DOT during testing, debugging and once compiled and working, returning to my good old COMMA,(hoping that this issue will be solved in a future firmware).

Regards,

Miguel