UKHeliBob:
How would you move to the next element of an array in Java ?
by indexing ie. profiles[6]
UKHeliBob:
How would you move to the next element of an array in Java ?
by indexing ie. profiles[6]
so my understanding till now is:
struct ProfileStruct {
double CommonHumid;
double CommonTemp;
int daysToHatch;
int daysToTurn;
int ProfileID;
String ProfileName;
} Chicken, quail, duck
Chicken.CommonHumid = 60;
So and with an array of function calls,
profiles[]{
profileAPI(parameters);,
profileAPI(parameters2);
}
and with profiles[1]; it will run the code profileAPI(parameters2);
is this right?? if not can I get the right way
You keep asking for what has already been given to you. My impression is that your programming knowledge is too basic for this project. The syntax of the code you posted above is complete nonsense. The solution was handed to you on a silver platter, in reply #2.
Suppose you have an array of three structs and assuming the values have been populated at the top of the program
Then you can create a variable that represents any one of the array elements like this
auto &myProfile = profileArray[n]; // where n is any of 0,1,2
Then you can refer to a profile element with
tempVal = myProfile.CommonTemp
This means that there is only one line in the code where you need to select the array element
...R
Okay! but the real problem here is how do I switch between functions on each button.
aproxdoesdev:
Okay! but the real problem here is how do I switch between functions on each button.
I'm not sure I understand.
Perhaps pressing the button would increment a number and the number could then be used to select the profile - something like this pseudo code
if button is pressed
ndx ++
if ndx > 2
ndx = 0 // to stay within limits
auto &myProfile = profileArray[ndx];
...R
aproxdoesdev:
Okay! but the real problem here is how do I switch between functions on each button.
Let's suppose that n is currently 0 so you are currently using profile 0, ie profileArray[0]
The user then presses the "next profile" button so you increment n, which is now 1 so you are using profileArray[1]
Is that what you have a problem with ?
UKHeliBob:
Is that what you have a problem with ?
I think so. It looks like the OP feels that there is some additional statement to be executed to say "I'm using this one" and since there isn't, is confused.
I have thought of such solution yesterday night, i was confused about the execution for the profileAPI() function. Using arrays is viable, but i don't know how to execute.. is it as simple as profiles[0];!?
If functions are not suited with arrays, i might have to hardcode.
i have an uno in the meantime but im getting a leorando with an Ethernet shield
which means i can add arrays using a website and configure a bunch of stuff.
Maybe give us a piece of code that is supposed to use one of the profile items and we can illustrate how to use the array of structs that has been proposed.
aproxdoesdev:
I have thought of such solution yesterday night, i was confused about the execution for the profileAPI() function. Using arrays is viable, but i don't know how to execute.. is it as simple as profiles[0];!?
Gibberish. You don't "execute" data.
aproxdoesdev:
If functions are not suited with arrays, i might have to hardcode.
More gibberish.
i have an uno in the meantime but im getting a leorando with an Ethernet shield
which means i can add arrays using a website and configure a bunch of stuff.
I don't see that being successful until you master some basic C++ programming skills.
I might not have used the exact same language as in Reply #31, but it does reflect my own view of the situation.
@aproxdoesdev, you need to make your best attempt to apply the ideas you have been given. If the program does not work then post the code and it will make it much easier to help you. At the moment everything you say is too theoretical.
...R
guys none of your help is true...
why would i use a profiles array
and why would i create a struct when i just can pass the parameters.
i realized that storing the function is not possible,
and not have 1quadrozillion if statements isn't possible
why would i use a profiles array
So that you can switch between them by just changing the value of one variable
why would i create a struct when i just can pass the parameters.
So that the data for each profile is kept in a consistent (structured) way and can be referred to in the same way whatever profile you are using just by using its array index
You seem to have missed the point of using structs to hold the data and missed the point even more of using an array of structs to hold the data of similar objects
aproxdoesdev:
guys none of your help is true...
Perhaps you need to study it more carefully because all of us believe it is true.
...R
okay so I structured my reply badly, I meant to say none of your help practically matters to my issue. It is more refined and all, but it takes more time to set up, and I know the result is better after all your additions.
Perhaps I can close this thread, and create it later when I have a better understanding, and finish the core functionality of my project. I guess I'll see you in some time.
I got some eggs today, and we bought an incubator controller at the beginning of the project, to use to study
and replicate, since I brought the eggs today, I'll run the clone for 10.5 days and then switch to mine.
I will have time to run some macros to create graphs and time to restructure my entire program.
Sincerely yours -
Aproximate.