Hi all!
i got a piece of code from C++ that i want to use according to Aurora synthax but now i am stuck. :
typedef WORD BOUNDSACTION;
const BOUNDSACTION BA_STOP = 0,
BA_WRAP = 1,
BA_BOUNCE = 2,
BA_DIE = 3;
I wonder what is the solution to use to expect better results.
But i assume the easier way is to use BOUNDSACTION as a structure like this :
struct BOUNDSACTION
{
const BA_STOP = 0;
const BA_WRAP = 1;
const BA_BOUNCE = 2;
const BA_DIE = 3;
}
Any suggestions ?
Regards!
Peter
I know nothing about C and little about Aurora but having a structure with all consts seems stange to me.
Using the structure, as you defined it, in a program looks sorta like this:
struct BOUNDSACTION
{
const BA_STOP = 0;
const BA_WRAP = 1;
const BA_BOUNCE = 2;
const BA_DIE = 3;
}
def myvar as BOUNDSACTION;
def var2 as int
...
if myvar.BA_STOP = 0 /* so sense at all */
var2 = myvar.BA_STOP /* sets var to 0 */
but the easier way to do that would be to forget the structure and define the const by themselves:
const BA_STOP = 0;
const BA_WRAP = 1;
const BA_BOUNCE = 2;
const BA_DIE = 3;
var2 = BA_STOP /* sets var to 0 */
But like I said, take what I say with a grain of salt until an Aurora user responds.
Larry
Y'all make things too complcated for yourself. In C the comma is a continuation of the previous action. C allows constants to have a 'type' since it is a type strict language. Aurora has types for constants as well, but they are automatic and you don't need to think about it much.
const BOUNDSACTION BA_STOP = 0,
BA_WRAP = 1,
BA_BOUNCE = 2,
BA_DIE = 3;
Is equivelent to:
const BA_STOP = 0;
const BA_WRAP = 1;
const BA_BOUNCE = 2;
const BA_DIE = 3;
There is no structure involved, so I don't no where you got the notion from ? The typedef is the same as Aurora's typedef, which is creating an alias for a built in type. Except ours is the opposite.
#typedef BOUNDSACTION WORD
And doesn't need the semicolon. All it does is tell the compiler that BOUNDSACTION is an alias for the type WORD so the following are equivelent.
WORD action;
BOUNDSACTION action;
Which is no different than how Emergence handles the typedef command as well.
Paul.
I agree. Forget the structure. But if you insist ;)
// compile as console program
struct BOUNDSACTION
{
int BA_STOP; // compiler won't accept 'const' as type
int BA_WRAP;
int BA_BOUNCE;
int BA_DIE;
}
sub main()
{
BOUNDSACTION myBounds;
myBounds.BA_STOP = 0;
myBounds.BA_WRAP = 1;
myBounds.BA_BOUNCE = 2;
myBounds.BA_DIE = 3;
OpenConsole();
print("Test\n");
print(myBounds.BA_STOP);
print(myBounds.BA_WRAP);
print(myBounds.BA_BOUNCE);
print(myBounds.BA_DIE);
print("\nPress any key...");
while GetKey()="";
CloseConsole();
return 0;
}
Messages crossing in the mail ;)
I thought Paul was working O/T.
Today is Sunday. I need at least one day of rest ;).
LOL!
It seems that everything went as expected ;D
Well, i did not really planed on using Structures as i already know how to implement my code in a better and easier way other then using Structures which would indeed be a way to cause me much pain for poor and inefficient results ::)
Thanks all! i had all the necessary information i need! ;)
Cheers!
Peter