HP Prime : Programming and the Comma
#1

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

#2

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!

#3

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

#4

Oh, yes, I do get an error with

Decimal Mark: Comma(,)

#5

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

#6

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.

#7

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.

#8

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



Possibly Related Threads…
Thread Author Replies Views Last Post
  Programming workaround for "prepend" HP PRIME Marek Russ 4 1,981 11-29-2013, 05:46 AM
Last Post: Marek Russ
  hp prime - programming with lists giancarlo 3 1,845 11-10-2013, 02:13 AM
Last Post: Giancarlo
  HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY Eddie W. Shore 5 2,303 11-07-2013, 12:25 AM
Last Post: Han
  HP Prime - programming bluesun08 2 1,433 11-04-2013, 04:31 PM
Last Post: bluesun08
  More undocumented programming limitations in the HP Prime Michael de Estrada 3 1,844 11-03-2013, 08:22 PM
Last Post: Michael de Estrada
  HP Prime questions: I/O and Meta programming Andy Gryc 2 1,478 10-31-2013, 11:22 PM
Last Post: Andy Gryc
  HP Prime Programming Tutorial #1: LOCAL, RETURN Eddie W. Shore 6 2,944 10-26-2013, 08:42 PM
Last Post: Miguel Toro
  HP Prime Programming Tutorial #2: MSGBOX, IF-THEN-ELSE, PRINT, FOR Eddie W. Shore 0 1,230 10-26-2013, 03:51 PM
Last Post: Eddie W. Shore
  HP Prime Programming: LOCAL Alberto Candel 3 1,482 10-07-2013, 01:31 AM
Last Post: cyrille de Brébisson
  HP Prime Programming options Egan Ford 8 2,451 10-06-2013, 10:44 AM
Last Post: Eddie W. Shore

Forum Jump: