dot in statements

Hello All. I've been trying to figure out the purpose/significance/result of the dot in some statements such as stepper1.set Acceleration(100.0); I'm talking about the dot(.) between 'stepper1' and 'set'. I've seen this in other statements too. What does it do? Why is it there? I've searched the internet and have gone through the Arduino Programming Notebook but have yet to find any reference to it. - Scotty

The dot separates a "member" of a class or structure from its owner. For example:

typedef struct {
   int x;
   int y;
} location;

void setup ()
{
 location myhome;
 
 myhome.x = 42;
 myhome.y = 56;
}

void loop () {}

The structure "location" has member variables x and y. Now once we have an instance of location (myhome in this example) we use the dots to set or get at the x and y variables.

The same thing applies to "member functions" such as setAcceleration. Effectively they are saying set the acceleration for this stepper motor (stepper1) rather than some other one.

It's the syntax used to call a function of an object. Standard stuff really.

Somewhere in your code you'll have something like:

Stepper stepper1;

So stepper1.setAcceleration calls the setAcceleration function of your stepper object, passing it the value in brackets (ie 100.0 in your case).

Cheers,

Nick was even more correct as he mentions the user of members variables as well! :slight_smile:

Scotty
I know how you feel.
I find some of the libraries the same. Not quite sure whats available.

Sorry pocketscience

Standard stuff really.

Is only any good when you manage to progress past beginner, newbie, total dumb a.s

Mark

Mark, all I meant to infer was that the "dot" is nothing magical or esoteric. No offence was intended - and I certainly wasn't implying anyone was dumb.

Any library you're using will have source files that exposes the functions you can access. Hopefully most libraries would include some samples or a readme to explain a bit more, but if nothing else you have the source code - and learning is fun! We've all been there! :slight_smile:

Cheers,

Thanks
No offence taken, and the dumb was not implied on anyone.

For those new to the mysteries of C/C++ reading through source is a bit like a foreign language.
I have looked into the keywords.txt file for hints before.

I have noted that in some cases there are explaination, and others there isn't.
The other thing is only using a subset of the commands (comfort zone) without realising there may be alternatives.

Thanks for the help.
Mark

Thanks all for your resonses. At my stage, even some of the terms and code within your responsed brought new confusion. Of course, as with any language, its to be expected. Little by little, piece by piece, it'll come together and become fun instead of a struggle. It's be good for my head.

Anyway, I suspect that from the one or two of the responses and the fact that there is no documentation for some of the code in the Arduino Reference area, that the answer(s) to my question(s) are within the library. Because someone mentioned 'source code', I investigated the folder of the library and found it. I'll be going through that in hopes it will be revealing.

  • Scotty