Commas in code

This forum is for all topics related to Simulator for Arduino v0.98. Please include sample code where possible.

Moderator: Adrian

jmi
Posts: 1
Joined: Sat Apr 20, 2013 5:34 am

Commas in code

Postby jmi » Sat Apr 20, 2013 6:17 am

Hi

I know that in previous versions comma and dot were not working correctly, unless you set your windows regional setting correctly.
But, looks like there is still some troubles...

At least fo my understanding followind shoudl work:

Code: Select all

mystring "10,20,30,40"

int commaA = mystring.indexOf(',');
int commaB = mystring.indexOf(',', commaA+1);
int commaC = mystring.lastIndexOf(',');

Serial.println("A:" + commaA);
Serial.println("B:" + commaB);
Serial.println("C:" + commaC);


This only returns 0 to all...

If i replace comma with space, it works little better.

Code: Select all

mystring "10 20 30 40"

int commaA = mystring.indexOf(' ');
int commaB = mystring.indexOf(' ', commaA+1);
int commaC = mystring.lastIndexOf(' ');

Serial.println("A:" + commaA);
Serial.println("B:" + commaB);
Serial.println("C:" + commaC);


But, in this example it returs correctly 3 for A, but also to B. Like it ignores option "commaA+1"
And of course C comes correctly.

- J

User avatar
Adrian
Super user
Posts: 56
Joined: Thu Jan 10, 2013 10:22 pm

Re: Commas in code

Postby Adrian » Fri May 03, 2013 10:35 pm

Hi jmi,

I'm sorry to hear that you are having problems. Does your code work correctly when run on the Arduino?

I take it that your country settings are correct? It does occasionally happen that bugs get folded back into the mixture.

Would you be kind enough to post a full working sketch? By that I mean a minimal (but full) sketch that shows the issue. It sounds rather pedantic, but ensures that you are not making school boy errors (we all do!), speeds up testing and prevents us (anyone testing your code) from jumping to conclusions / guessing about missing parts.

Loving the fact that you've used the code tags :)

At the risk of teaching anyone to suck eggs, demonstration code should include....
#includes, #defines, all variable definitions, setup(), loop() and of course any subroutines - comments are always appreciated too :)

Hope to hear from you soon
Adrian
Apologies for being opinionated - it's nothing personal, feel free to complain.
usual system: Pro V0.98 Arduino Mega 2560 Samsung i5-3210M 2.5Ghz 6GB windows home premium SP1


Return to “Version 0.98”

Who is online

Users browsing this forum: No registered users and 1 guest