PDA

View Full Version : Sequential commands


Dirk98
18-09-2004, 09:46 PM
Hello guys, need your help:

When I want to run a simple Sequential loop of 2 commands on a single joystick button I'm using the following script:

SEQUENCE
// First Command Operates on the first press of Joystick 1 Button 1
WHILE( JS1.B1 );
CMS.B1 = TRUE;
DELAY( 2 );
CMS.B1 = FALSE;
DELAY( 2 );
// Second Command Operates on the second press of Joystick 1 Button 1
WHILE( JS1.B1 );
CMS.B2 = TRUE;
DELAY( 2 );
CMS.B2 = FALSE;
DELAY( 2 );
ENDSEQUENCE

The above sequence works for me as follows:
1st press: execute command 1
2nd press: execute command 2
3rd press: execute command 1 - etc. loop

But now I want the sequence to work as follows:

Version1:
1st press: execute command 1
2nd press: execute command 2
3rd press: execute command 1 - etc. loop of commands 1&2
UNTILL any other BUTTON on CH combo is pressed, then from command 1 ONLY

Version2:
Press 1st time: - command 1
Press 2nd time: - command 2
Press 3rd time: - command 3
Press 4th time: - command 2
Next presses - loop of commands 3 and 2

Version3:
Press 1st time: - command 1
Press 2nd time: - command 2
Press 3rd time: - command 2
Next presses - always command 2

Version4:
Press 1st time: - command 1
Press 2nd time: - command 2
Press 3rd time: - nothing
UNLESS a specific Button 2 on the CH Combo is pressed, then starts all over again.

Guys, desperately need examples of the scripts for the above, no way I can write them by myself. With your kind help though there's a chance I will dig it in the future.

Many thanks for your answers.
Dirk. :cheers:

Dirk98
20-09-2004, 01:42 PM
Need more please:

Need to control pressing of buttons 1 to 5 on keyboard with JS1.B6 and JS1.B8 in the both direction, from the position (1to5) where the previous click occured. Could you please paste the script here.

Many thanks,
Dirk.

JNOV
20-09-2004, 07:02 PM
Here's my take on the first four (I'm not sure what you mean by your last post, but if you'll clarify, I'll take a crack at it.) I'm at work on my lunch hour, so I can't test these, so I hope they work. :)

== Version 1 ===

%define AnyKeyBut (js1.b2 or js1.b3 or . . . or js1.b32 or js2.b1 or . . . or js2.b32)

if (!b255) then
b255 = TRUE;
BreakKey = FALSE;
endif

sequence
wait(AnyKeyBut);
BreakKey = TRUE;
endsequence

// Add this block if you want to be able to get back into the 1-2-1-2 sequence
//
//sequence
//wait(SomeOtherButton); // Pick a button or buttons here
//BreakKey = FALSE;
//endsequence

sequence
wait(js1.b1);
cms.b1 = TRUE;
delay(2);
cms.b1 = FALSE;
wait(js1.b1);
cms.b1 = BreakKey;
cms.b2 = not BreakKey;
delay(2);
cms.b1 = FALSE;
cms.b2 = FALSE;
endsequence


=== Version 2 (1-2-3-2-3-2-...) ===

%define FirstTime b1

if (!b255) then
b255 = TRUE;
FirstTime = TRUE;
endif

// Add this block if you want to be able to reset "FirstTime"
// variable to cycle through the initial 1-2-3 sequence again
//
//sequence
//wait(SomeButton);
//FirstTime = FALSE;
//endsequence

sequence
wait(js1.b1 and FirstTime);
cms.b1 = TRUE;
delay(2);
cms.b1 = FALSE;
FirstTime = FALSE;
endsequence

sequence
wait(js1.b1 and not FirstTime);
cms.b2 = TRUE;
delay(2);
cms.b2 = FALSE;
wait(js1.b1 and not FirstTime);
cms.b3 = TRUE;
delay(2);
cms.b3 = FALSE;
endsequence


=== Version 3 (1-2-2-2...) ===

%define FirstTime b1

if (!b255) then
b255 = TRUE;
FirstTime = TRUE;
endif

// Add this block if you want to be able to reset "FirstTime"
// variable to cycle through the initial 1-2-2 sequence again
//
//sequence
//wait(SomeButton);
//FirstTime = TRUE;
//endsequence

sequence
wait(js1.b1);
cms.b1 = FirstTime;
cms.b2 = not FirstTime;
delay(2);
cms.b1 = FALSE;
cms.b2 = FALSE;
FirstTime = FALSE;
endsequence


Version 4 (1-2-nothing . . . button-1-2)

%define RestartKey js1.bx // whatever you want
%define Finished b1

if (!b255) then
b255 = TRUE;
Finished = FALSE;
endif

sequence
wait(RestartKey);
Finished = FALSE;
endsequence

sequence
wait(js1.b1 and not Finished);
cms.b1 = TRUE;
delay(2);
cms.b1 = FALSE;
wait(js1.b1);
cms.b2 = TRUE;
delay(2);
cms.b2 = FALSE;
Finished = TRUE;
endsequence


Note that I've included no logic to select from among the four versions, as I didn't know how or if you wanted to use them in the same script.

Good luck,

JNOV

Dirk98
13-12-2004, 12:08 AM
Wow, have just discovered your response JNOV, thanks so much! Need to go through this again, I know it was intended for changing modes in LOMAC. Cool :cheers:

Dirk98
27-12-2006, 02:39 PM
Here's my take on the first four (I'm not sure what you mean by your last post, but if you'll clarify, I'll take a crack at it.) I'm at work on my lunch hour, so I can't test these, so I hope they work. :)

== Version 1 ===

%define AnyKeyBut (js1.b2 or js1.b3 or . . . or js1.b32 or js2.b1 or . . . or js2.b32)

if (!b255) then
b255 = TRUE;
BreakKey = FALSE;
endif

sequence
wait(AnyKeyBut);
BreakKey = TRUE;
endsequence

// Add this block if you want to be able to get back into the 1-2-1-2 sequence
//
//sequence
//wait(SomeOtherButton); // Pick a button or buttons here
//BreakKey = FALSE;
//endsequence

sequence
wait(js1.b1);
cms.b1 = TRUE;
delay(2);
cms.b1 = FALSE;
wait(js1.b1);
cms.b1 = BreakKey;
cms.b2 = not BreakKey;
delay(2);
cms.b1 = FALSE;
cms.b2 = FALSE;
endsequence

JNOV, have just tried the above case and it gives me ERROR: (54)ENDIF exepcted but "[" found. Could anyone pls check the syntax?

Thanks!