Need help inserting script into Maestro Windows Controller

Hello,

I’d like to first make it known that I am by NO MEANS a programmer. A few years ago I bought some working “caution lights” for my racing simulator on my computer. The guy I got it from used these parts and software. The first time I used it, I cut and pasted the script directly into the script tab of the Maestro Windows Controller. I recently upgraded my Motherboard and CPU and have since now lost the functionality. I had to download and reinstall everything including the caution light software. When I tried to cut and paste into the script tab like last time, I either forgot to add/delete something or just plain not doing it right. I keep getting the following error - Subroutine call overflow/underflow

Can someone please examine the below file and reformat so it will work properly? Again, I’m not at all a coder so EVERYTHING in the script might as well be written in Chinese.

Thanks for any and all help and support!

[code]sub greenout
resetlights
0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 rgb
5000 delay
0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 rgb
return

sub greenwaving
resetlights
begin
green-flash
repeat
return

sub whiteflag
resetlights
begin
1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 1023 rgb
200 delay
0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 rgb
repeat
return

sub CheckeredFlag
resetlights
Begin
white-flash
repeat
return

sub resetlights
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 rgb
return

sub cautionlights
resetlights
begin
yellow-flash
1023 800 0 1023 800 0 1023 800 0 1023 800 0 1023 800 0 1023 800 0 1023 800 0 1023 800 0 rgb
10000 delay
repeat
return

sub blackflag
begin
1023 0 500 1023 0 500 1023 0 500 1023 0 500 1023 0 500 1023 0 500 1023 0 500 1023 0 500 rgb
100 delay
0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 rgb
repeat
return

sub halfway
begin
0 1023 0 0 30 0 0 1023 0 0 30 0 0 1023 0 0 30 0 0 1023 0 0 30 0 rgb
0 30 0 0 1023 0 0 30 0 0 1023 0 0 30 0 0 1023 0 0 30 0 0 1023 0 rgb
repeat
return

sub blueflag2
begin
0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 rgb
0 0 900 0 0 900 0 0 900 0 0 900 0 0 900 0 0 900 0 0 900 0 0 900 rgb
0 0 800 0 0 800 0 0 800 0 0 800 0 0 800 0 0 800 0 0 800 0 0 800 rgb
0 0 700 0 0 700 0 0 700 0 0 700 0 0 700 0 0 700 0 0 700 0 0 700 rgb
0 0 600 0 0 600 0 0 600 0 0 600 0 0 600 0 0 600 0 0 600 0 0 600 rgb
0 0 500 0 0 500 0 0 500 0 0 500 0 0 500 0 0 500 0 0 500 0 0 500 rgb
0 0 400 0 0 400 0 0 400 0 0 400 0 0 400 0 0 400 0 0 400 0 0 400 rgb
0 0 300 0 0 300 0 0 300 0 0 300 0 0 300 0 0 300 0 0 300 0 0 300 rgb
0 0 200 0 0 200 0 0 200 0 0 200 0 0 200 0 0 200 0 0 200 0 0 200 rgb
0 0 100 0 0 100 0 0 100 0 0 100 0 0 100 0 0 100 0 0 100 0 0 100 rgb
0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 rgb
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 rgb
0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 0 0 50 rgb
0 0 100 0 0 100 0 0 100 0 0 100 0 0 100 0 0 100 0 0 100 0 0 100 rgb
0 0 200 0 0 200 0 0 200 0 0 200 0 0 200 0 0 200 0 0 200 0 0 200 rgb
0 0 300 0 0 300 0 0 300 0 0 300 0 0 300 0 0 300 0 0 300 0 0 300 rgb
0 0 400 0 0 400 0 0 400 0 0 400 0 0 400 0 0 400 0 0 400 0 0 400 rgb
0 0 500 0 0 500 0 0 500 0 0 500 0 0 500 0 0 500 0 0 500 0 0 500 rgb
0 0 600 0 0 600 0 0 600 0 0 600 0 0 600 0 0 600 0 0 600 0 0 600 rgb
0 0 700 0 0 700 0 0 700 0 0 700 0 0 700 0 0 700 0 0 700 0 0 700 rgb
0 0 800 0 0 800 0 0 800 0 0 800 0 0 800 0 0 800 0 0 800 0 0 800 rgb
0 0 900 0 0 900 0 0 900 0 0 900 0 0 900 0 0 900 0 0 900 0 0 900 rgb
0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 0 0 1023 rgb
repeat
return

sub blackflagrepair
begin
1023 0 500 1023 0 0 1023 0 0 1023 0 0 1023 0 500 1023 0 500 1023 0 500 1023 0 500 rgb
1023 0 0 1023 0 500 1023 0 0 1023 0 500 1023 0 0 1023 0 0 1023 0 0 1023 0 0 rgb
repeat
return

setting the RGB value of a ShiftBrite/ShiftBar.

example usage: 1023 511 255 rgb

sub rgb
0 send_bit # this bit does not matter
0 send_bit # the “address” bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value
0 send_bit # this bit does not matter
0 send_bit # the “address” bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value
0 send_bit # this bit does not matter
0 send_bit # the “address” bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value
0 send_bit # this bit does not matter
0 send_bit # the “address” bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value
0 send_bit # this bit does not matter
0 send_bit # the “address” bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value
0 send_bit # this bit does not matter
0 send_bit # the “address” bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value
0 send_bit # this bit does not matter
0 send_bit # the “address” bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value
0 send_bit # this bit does not matter
0 send_bit # the “address” bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value
0 1 8000 1 servo servo # toggle the latch pin
return

sends a numerical value as a sequence of 10 bits

sub send_10_bit_value
512
begin
dup
while
over over bitwise_and send_bit
1 shift_right
repeat
drop drop
return

sends a single bit

sub send_bit
if 8000 else 0 endif
2 servo # set DATA to 0 or 1
0 0 8000 0 servo servo # toggle CLOCK
return

sub input
5 get_position
dup 150 less_than
if
drop 0
else
1023 min 4 times
endif
return

sub random
20 begin
dup while
input input input rgbn
1 minus repeat
drop return

sub latch
0 1 8000 1 servo servo # toggle the latch pin
return

sub strobeon
16 begin
dup while
1023 1023 1023 RGB2
1 minus repeat
drop return

sub strobeoff
16 begin
dup while
0 0 0 RGB2
1 minus repeat
drop return

sub redstrobe
50
begin
dup
while
red
off
1 minus
repeat
drop return

sub strobe3
5 begin
dup while
strobeon
latch
strobeoff
latch
1 minus repeat
drop return

sub blue-scroll
5 begin
dup while
blue
off
off
off
off
off
off
off
off
off
off
off
off
off
off
off
1 minus repeat
drop return

sub green-scroll
5 begin
dup while
green
off
off
off
off
off
off
off
off
off
off
off
off
off
off
off
1 minus repeat
drop return

sub red-scroll
5 begin
dup while
red
off
off
off
off
off
off
off
off
off
off
off
off
off
off
off
1 minus repeat
drop return

sub blue-flash
20 begin
dup while
blue
off
off
off
off
1 minus
repeat
drop return

sub red-flash
20 begin
dup while
red
off
off
off
off
1 minus
repeat
drop return

sub yellow-flash
20 begin
dup while
yellow
off
off
off
off
1 minus
repeat
drop return

sub green-flash
20 begin
dup while
green
off
off
off
off
1 minus
repeat
drop return

sub white-flash
20 begin
dup while
white
off
off
off
off
1 minus
repeat
drop return

sub yellow
1023 800 0 rgbn
return

sub pink
1000 200 200 rgbn
return

sub green/red
1023 900 0 rgbn
return

sub green
0 1023 0 rgbn
return

sub red
1023 0 0 rgbn
return

sub blue
0 0 1023 rgbn
return

sub greenredflash
10 begin
dup while
green/red
green/red
green/red
green/red
off
1 minus
repeat
drop return

sub pinkflash
10 begin
dup while
pink
pink
pink
off
off
1 minus
repeat
drop return

sub bluestrobe
50
begin
dup
while
blue
off
1 minus
repeat
drop return

10 begin
dup while
pink
pink
pink
pink
off
1 minus
repeat
drop return

sub white5
10 begin
dup while
white
white
white
white
white
off
1 minus repeat
drop return

sub white
1023 1023 1023 rgbn
return

sub white2
1023 1023 1023 rgb2
delay1
return

sub off
0 0 0 rgbn
return

sub on
50
begin
dup
while
white
off
1 minus
repeat
drop return

sub clear
16
begin
dup
while
0 0 0 rgb2
1 minus
repeat
drop return

sub Colour
10
begin
dup
while
1023 0 0 rgbn
delay1
900 0 0 rgbn
delay1
700 0 0 rgbn
delay1
300 0 0 rgbn
delay1
0 0 0 rgbn
delay1
0 300 0 rgbn
delay1
0 700 0 rgbn
delay1
0 900 0 rgbn
delay1
0 1023 0 rgbn
delay1
0 900 0 rgbn
delay1
0 700 0 rgbn
delay1
0 300 0 rgbn
delay1
0 0 0 rgbn
delay1
0 0 300 rgbn
delay1
0 0 700 rgbn
delay1
0 0 900 rgbn
delay1
0 0 1023 rgbn
delay1
0 0 900 rgbn
delay1
0 0 700 rgbn
delay1
0 0 300 rgbn
delay1
300 300 700 rgbn
delay1
300 700 900 rgbn
delay1
700 900 1023 rgbn
delay1
900 1023 1023 rgbn
delay1
1023 1023 1023 rgbn
delay1
1023 900 900 rgbn
delay1
1023 700 700 rgbn
delay1
1023 300 300 rgbn
delay1
1023 0 0 rgbn
delay1
1 minus
repeat
drop return

Subroutine for setting the RGB value of a ShiftBrite/ShiftBar.

example usage: 1023 511 255 rgb

sub rgbn
0 send_bit # this bit does not matter
0 send_bit # the “address” bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value
0 1 8000 1 servo servo # toggle the latch pin
return

Subroutine for setting the RGB value of a ShiftBrite/ShiftBar.

example usage: 1023 511 255 rgb

sub rgb2
0 send_bit # this bit does not matter
0 send_bit # the “address” bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value
return

sub delay1
50 delay
return[/code]

Hello.

The “Subroutine call overflow/undeflow” error you are seeing in the Maestro Control Center indicates that the script has a return command without a corresponding subroutine call or the number of nested subroutines exceeds the call stack depth. For more details, see the description for Script call stack error (bit 7) under the “Errors” section of the Maestro’s user’s guide.

Considering that your script is quite lengthly, I do not think it is practical to ask someone to try to understand the code and fix the problem. I recommend contacting the person, who you got the script from, to help you fix the issue. If that is not an option, then I suggest you try simplifying the script to where it should work, but does not, or find the line in the script that is causing the error (by stepping through the script using the "Step Script " button in the “Script” tab of the Control Center).

- Amanda

Thank you for your reply! Unfortunately, I can’t get a hold of the guy who did it and what you mentioned, “the script has a return command without a corresponding subroutine call or the number of nested subroutines exceeds the call stack depth”, makes no sense to me. I read the description in the link you provided and again makes no sense. I don’t mind doing what needs to be done if the work of going through and finding the issue is too much for someone to do, however, what is it I’m looking for if I do the step by step function? An empty space, extra space after a return etc…? I have NO idea how any of this works unfortunately, so whatever you can provide in layman’s terms would be greatly appreciated. I did see that apparently I am maxing out of 126/126. Is that the number of rows in the script and that its too long?

Thanks again for your help.
Best Regards.

That is unfortunate.

The subroutine level counter you are seeing indicates the call stack depth (or the number of subroutine levels used) during the program’s execution; it does not indicate the minimum number of code lines (or rows) in a script.

I took another look at your script and noticed that it only consists of subroutines definitions with no main loop. I tested your code to confirm that the call stack underflow error occurs at the return command of sub greenout, where the program is trying to return to a point that is not defined. At the start of the script, the program just fell through into the greenout subroutine and immediately began executing it. One way to avoid getting the underflow error, you could define a BEGIN/REPEAT block at the start of your script. For example:

BEGIN
  greenout	# defined starting point, return here after executing subroutine
REPEAT

sub greenout
  #...rest of your script

Alternatively, if you do not want the program to repeat, you could use the QUIT command:

greenout	# defined starting point, return here after executing subroutine
QUIT		# stop the script

sub greenout
  #...rest of your script

Please note that implementing either of the examples above will get rid of the “Subroutine overflow/underflow” error, but it will probably not make your system work as it is intended. Again, you will probably need to contact the person you got the system from in order to get the product functioning as intended.

- Amanda