HP Forums
HP Prime : Programming and the Comma - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: HP Prime : Programming and the Comma (/thread-253754.html)



HP Prime : Programming and the Comma - Miguel Toro - 10-24-2013

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


Re: HP Prime : Programming and the Comma - Alberto Candel - 10-24-2013

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!


Re: HP Prime : Programming and the Comma - Miguel Toro - 10-24-2013

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


Re: HP Prime : Programming and the Comma - Alberto Candel - 10-24-2013

Oh, yes, I do get an error with

Decimal Mark: Comma(,)




Re: HP Prime : Programming and the Comma - Han - 10-24-2013

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 (,)?




Re: HP Prime : Programming and the Comma - Miguel Toro - 10-24-2013

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.




Re: HP Prime : Programming and the Comma - Marcus von Cube, Germany - 10-25-2013

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.


Re: HP Prime : Programming and the Comma - Miguel Toro - 10-25-2013

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