How do you expand a script for multiple widgets?

Greetings everyone …

I have a few question related to scripting multple widgets but I have no scripting experience.
Ive looked at some code & I see some rules.

1- Insert widget into the rack then load the script or load script then insert widget in the rack.
2 - The script & every widget label in the highlighted properties must match.

This script by @pianopaul is for a momentary red button …I can change the button type to a different colour but the references to the new button must match the new widget. highlighted

MIN : MidiInBlock
BUTTON : Widget
n : NoteMessage

n := MakeNoteMessage(C3, 100)

on WidgetValueChanged (newValue : double) from BUTTON
if newValue == 1.0 then
ScheduleMidiEvent(MIN, n, 200)

on NoteEvent (n : NoteMessage) from MIN

How would I expand this script to 100 buttons in the same rack? I know i’ll have to create 100 buttons with different names . Would the additional code for the additional buttons appear before the end statement?


Button1: widget
Button2: widget
Button3: widget
Button4: widget
Button5: widget
Button6: widget

Or can I replicate the code , change the characteristics & paste additional script on the after the end statement.

You know you can send Note Messages without scripting?

It’s the momentary button feature I want to expand upon for touch screens. I think 100 momentary buttons per rack should cover the majority of uses. Eg midi sketchpad & keystroke macros…mixing desk insert fx & solos ,dj mixer eq kill effects…guitar pedal effects.