Easy C Relay Programming

for easy C,
i know you can set a relay to a button and have that relay in a set position when you hold the button, but can you, in easy c, have it so you click the button once and the relay stays on, and click it again to switch the relay reverse or off? i know the wording of this question is not too great, but if you can decipher it, an answer would be great!

You want the relay to toggle. Its not too complicated to do.
This example will toggle a relay when the trigger is pulled on the first joystick.

char relayPos = 0;    //Holds the current position of the relay
char relayRelease = 1;    //Holds if trigger has been released yet
if(GetOIDInput(1, 1) && relayRelease)    //If trigger is pressed after being released
    if(relayPos == 1)
        SetRelay(1, 0, 1);
        relayPos = 0;
        SetRelay(1, 1, 0);
        relayPos = 1;
    relayRelease = 0;    //Set trigger as pressed
}else if(GetOIDInput(1, 1)==0)    //trigger released
    relayRelease = 1;

Note that the above is for a double solenoid. If you are using a single solenoid then change the SetRelays to SetRelay(1, 0, 0) and SetRelay(1, 1, 0)