Originally posted by speve
if (Select==1)
BasicSaveStructure(), SaveNormal();
else if (Select==2)
BasicSaveStructure(), Save90();
else if (Select==3)
BasicSaveStructure(), Save180();
I have two suggestions that I hope will be useful to you.
The first is to not have so many functions that do the same (or very similar) things. With your BasicSaveStructure() preceeding the "rotation save" function it is clear that every save has some things in common, and you also want to be able to save at different rotations. Will something like this work for you?
Code:
void SaveFile( short rotation )
{
/* Do your 'basic save' tasks here */
/* Do you rotation specific tasks here */
}
A rotation value of zero is 'normal'. A negative value for rotation indicates it is inverted (-90 is Invert90).
My second suggestion is to replace your large if .. else if block with a switch statement:
Code:
short rotation;
switch (Select)
{
case (1):
rotation = 0;
break;
case (2):
rotation = 90;
break;
case (3):
rotation = 180;
break;
case (4):
rotation = 270;
break;
case (5):
rotation = -360; /* perhaps you have a better value for this */
break;
case (6):
rotation = -90;
break;
case (7):
rotation = -180;
break;
case (8):
rotation = -270;
break; /* not needed, but a nice coding habit to get into */
}
SaveFile( rotation );
You have now accomplished your basic and rotation specific tasks with a single function call. If I have misunderstood your question, feel free to point me in the right direction