Help with arrays, please

That sounded like an easy fix, but then the compiler complained about the lights variable. Though lights seems to define an array of listed variables, does it need itself defined in the var list at head of script?

Again, the error message is telling you that the variable ‘lights’ is not declared.

Unlike languages like Python, all variables in GPScript must be declared before they can be used.

In your example, “lights” is not defining an array of listed variables, it is being assigned an array (not a list) of values, i.e. widget variables

In your particular example, you need to therefore write

var
   lights : widget array // Declare an array that can store widgets

initialization
   lights = [cl,cr,ll,hl]
end

Answers my last question perfectly, confirmed my hunch that a definition was needed and script compiles successfully. Thank you very much!

This specific example is documented in the GPScript manual

https://gigperformer.com/docs/GPScript36/content/language-manual/language-constructs.html#declarations

I maybe misunderstanding you, but have you tried this?

The buttons initialise with green LED if it is programmed to do something.
Press a button, the LED goes red. Press another, it goes red and the other(s) return to green. 4 char LED display shows name of current pressed button. Buttons are sending PC messages here, but could be anything…



thanks - i looked at that functionality for a bit but it confused me - plus, in my case i wanted the lights to be off when not green. but, i’ll look at it again, and maybe red-when-not-green is ok! (part of it is because i had the top row turn red when on, the bottom row green when on. i had a good reason for that once, but i don’t remember it now!)

No worries, here you go!
modline 1 makes it initialise with LEDs off
modline 2 is the MIDI control you want (in my case, PC message)
modline 3 turns red LED on when button is pressed
modline 4 turns red LED off when other button is pressed

Ha!
Similarly, I was only using green LEDs as I had a SoftStep 1 and couldn’t use the backlight because of the EM noise it induces. Made it possible to see the buttons in the dark. Just haven’t changed the patch since I upgraded.

thanks! i will reply privately so as not to completely turn this into a Soft Step forum!