08-17-2007 03:26 PM
08-17-2007 03:43 PM
I'm sorry, but I'm working with LV7, and can't take a look at what you did. Personally, though, I think I'd create a 1D array of elements {2,5,1,3,4}. Using the provided inputs and a "Search 1D Array" node, you could find the indices of the two tanks. Subtracting these would give you which direction (negative value for one direction, positive the other) and, if needed, how far to go.
Probably more elegant solutions (and I apologize if your current method already trumps mine, or if I'm missing some important detail), but those are my initial thoughts on it.
08-17-2007 03:46 PM
08-17-2007 03:47 PM
Hey Coreys! Thanks for the response!
The first part of our programs are the same (the array bit), but the way you did the subtracting of the indices is much better than mine. I checked to see if they were equal, if they were, no move, if they weren't I did a second comparison to see if the first was greater than the second. I had a case structure within a case structure and while I was coding that, it nagged me that there had to be a better way.
Thank you!
08-17-2007 03:52 PM - edited 08-17-2007 03:52 PM
Message Edited by jmpugh on 08-17-2007 03:58 PM
08-17-2007 03:52 PM
Glad to hear I could help!
Sometimes all it takes is a second viewpoint (or possibly no view at all!) ![]()
08-17-2007 03:53 PM - edited 08-17-2007 03:53 PM
You can eliminate half the code by defining the enum in the same order as the tanks, then comparing enums directly instead of array indeces. See attached code.
Message Edited by tbob on 08-17-2007 01:54 PM