Serial.print modifies variable

I inserted a code line like: Serial.print(x);

I seems that this modifies the variable x to a very low value/

In my sketch x was defined as a LONG

See both small examples in the attachements.

Who can explain this problem?

Wim

UTouch_QuickDraw.ino (1.13 KB)

with_print.ino (1.23 KB)

  long x, y;

Just how big IS your touch screen? It's hard to imagine it being more than 32,768 pixels long or high.

if ((x!=-1) and (y!=-1))

"and" ?? Where does THAT come from, and is it actually doing what you think it is doing?

I'm pretty certain that print is NOT broken. What makes you think that x and y are having their value changed by print? There's nothing in your examples that does anything with them after they were printed...

(huh. I guess "and" is a C++ thing...)

(huh. I guess "and" is a C++ thing...)

No, it's an Arduino thing. Another stupidity passed off to prevent users from actually learning to program properly.

It's a C++ thing, PaulS:

Can you give a link to your libraries please? The exact file? I got:

404 - Page not found
I am sorry, but the page you have requested no longer exists (or has never existed).

I am not sure what you have done to deserve this, but it was probably very bad.

I have no idea what you are looking for...

If you got here by clicking on a link on another site I would appreciate it if you could notify the admin of the offending server.