Expressions to make peg move

I’m trying to learn how expressions work and I don’t have a lot of programming experience. I have Peg A and Peg B, and when I move Peg A I want to have Peg B move at the same time. I have that part done, but I also want when Peg A moves past a certain point, Peg B moves back in the opposite direction.

So let’s say Peg A is at point 0, then moves in the x direction to the right. Peg B follows in the same direction. When Peg A reaches 5, Peg B switches direction heading to the left. As Peg A keeps going to the right, Peg B keeps going to the left.

This is what i would like to do, and I imagine it is an if and else statement with >5 and <5, but I can’t seem to figure it out. Any help or a pointer to documentation on writing expressions would be greatly appreciated.

I tried this a while ago. In my experience, expressions do not work in Harmony as you would expect or are used to from other programs.
It seems like they are not “live” and behave more like scripts that need to be refreshed manually. This is one of the big “gotcha’s” when it comes
to rigging in Harmony.

If I am wrong about this, please let me know. I would really love to be wrong.