Home Forums General Programming Lua in Ctrlr – list of frequently used commands Reply To: Lua in Ctrlr – list of frequently used commands

#14112
lfo2vco
lfo2vco
Participant

OK, I have a couple of useful functions that can be applied to strings containing patch names for instance.
—————————————————————————————————————
The following Function extracts a piece of the string from characters 1 to 16

function edit (s)
	return (string.sub(s,1,16))
end

nameEdit = (edit(myString))

—————————————————————————————————————
The following Function removes whitespace (spaces) from either end of a string

function trim (s)
	return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end

nameTrim = (trim(myString))

—————————————————————————————————————

Hope these prove useful to others.