![]() |
Aliases
Can you make a temp variable, give it like 4 aliases and use anyone of them? This may be very effective if you use put and get statements because of our variable space.
|
I haven't seen anything that would keep you from doing this...
|
Re: Aliases
Quote:
|
The way I understand it, you can use as many aliases as you want because all the variables are turned into memory addresses when tokenized.
|
When a varable is aliased is the value the same for all aliased names?
|
Quote:
|
sooo....
so then why alias a variablle to different names? if they all equal the same thing, why not just use the same one again and again, it would save code and space. Is it just for ease and readability?
-Kesich |
Re: sooo....
Quote:
|
Re: sooo....
Quote:
Bingo. When your robot breaks down next year and you urgently need it to do a demonstration to get some team funds, you'll want to know what the heck you were thinking when you wrote the code. I always use the default names for the SERIN so I know what's being input, then I alias them for my code so that I know what I'm doing. It helps the train of thought because then you can read it more like a sentence. |
Re: sooo....
Quote:
Besides code readability, a reason to use aliases the way Jnadke said is to quickly change the input mapping. If you want to switch your drive stick to port 2 instead of port 1 and you don't have any aliases, you have to change all the occurrances of p1_x and p1_y to p2_x and p2_y respectively. If you use aliases such as drive_stick_x and drive_stick_y, all you have to do is change the alias in one place and you're done. You should do the same for your outputs as well. Or you can write your motor output speeds to scratchpad RAM locations (such as s_left_drive_speed) and then fetch your speed to the correct pwm variable right before the Serout. Those are just a few tricks to make changing input & output mappings less of a headache. |
uhhuh
ahh i see...., so it makes it much easier. (you'll have to excuse me, im a rookie programmer, err the only programmer on a rookie team, and ive taught myself all of the code, so i have learned to question EVERYTHING)
-Kesich P.S. I've had that problem many times before, changing ports that is, and i find it to be a pain in th neeck, expecially when you miss ONE of them and it destroys the entire operation. |
| All times are GMT -5. The time now is 04:28. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi