What I’m hopping to accomplish isn't to get it to work... it's to consolidate a 
whole bunch of 
functions and procedures that are all exactly the same except for which axis I 
am working with...

I have 9 possible Axis, X,Y,Z,W,L.R,A,B,C

And I have Procedures:

Procedure Move_X;
Begin
  DoSomething(Variable1.X);
  DoAThing2;
  DoAThing3;
...
   Do more things that are the same all the time
...  
  DoSomethingElse(Variable2.X);
  Variable3.X := SomeFormula(Variable4.X * ScaleFactor.X);
...
70 lines of things what work only with the .X variable
...
End;

Procedure Move_Y;
Begin
  DoSomething(Variable1.Y);
  DoAThing2;
  DoAThing3;
...
   Do more things that are the same all the time
...  
  DoSomethingElse(Variable2.Y);
  Variable3.Y := SomeFormula(Variable4.Y * ScaleFactor.Y);
...
70 lines of things what work only with the .Y variable
...
End;

...
Same thing 7 more times
...


This is a tedious situation.  If I want to change something I have to copy and 
paste it 9 times then go fix all the variables 9 times.. and it's easy to make 
a mistake.

What I want is just one uncomplicated procedure:

Procedure Move_It(Axis_Letter:Char);
Begin
  DoSomething(Variable1. Axis_Letter);
  DoAThing2;
  DoAThing3;
...
   Do more things that are the same all the time
...  
  DoSomethingElse(Variable2. Axis_Letter);
  Variable3. Axis_Letter := SomeFormula(Variable4. Axis_Letter * ScaleFactor. 
Axis_Letter);
...
70 lines of things what work only with the . Axis_Letter variable
...
End;


If I need a bunch of case statements, it's atcually worse than if I just have 
separate procedures.
Procedure Move_It(Axis_Letter:Char);
Begin
Case Axis_Letter of
X:
   Begin
      DoSomething(Variable1. X);
    End;
Y:
   Begin
      DoSomething(Variable1. Y);
    End;
...
7 more times
...
End;
  DoAThing2;
  DoAThing3;
...
   Do more things that are the same all the time
...  
Case Axis_Letter of
X:
   Begin
     DoSomethingElse(Variable2. X);
     Variable3. X := SomeFormula(Variable4.X * ScaleFactor. X);
   End;
Y:
   Begin
     DoSomethingElse(Variable2. Y);
     Variable3. Y := SomeFormula(Variable4.Y * ScaleFactor.Y);
   End;
...
7 more times
...
...
70 lines of things that all have a 9 case statements, sometimes I can combine 
them, most of the time not.
...
End;

James

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to