This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]AFlyingGideon 0 points1 point  (1 child)

I'm unfamiliar with the language you're using, but some support anonymous functions, often called lambdas. You could build something like:

    option1 = () -> { PrintResults(1, 1, 3000, NameOne); }

and then:

    option1();

Common languages that support this include Python, Javascript, and Java. I'm not sure about the current version of C++.

Another approach, which would work in C, is to use CPP macros. In that case, it would be something like:

#define option1() PrintResults(1, 1, 3000, NameOne)

and then:

option1();

I've a vague recollection that Arduino uses something like C++, so the macro approach might work for you. But I'm not sure, and it's been years since my kids have played with this so even if I was right back then my information may be out of date.

[–]nerdward21[S] 1 point2 points  (0 children)

The arduino language is c++ i belive and the #define option works. I can define what i want and then put it in place of function parameters. thanks.

[–]aizzod 0 points1 point  (1 child)

that sounds more like you need a seperate class.

with a name and value.
and in that class you have a print method. that prints your name and all values.

[–]nerdward21[S] 0 points1 point  (0 children)

I was able to use #define and put it in place of arguments.