I’m getting text from a uiLabel, this works fine. However the text come from the patch name of a Sysex Dump and there are 15 bytes allocated to the for this task. So if the name is twelve characters long the remaining three characters get filled with spaces thus:
I might not be explaining this clearly but here’s vaguely how I would approach it:
Before placing HEX in the name field of a Save File Window, assign the value of each byte of HEX each to a unique variable. Check each variable starting from the last to see if it’s value is 20. If the last value in the sequence == 20, truncate it, then check the next and continue to check the next last variable’s value. By truncate I mean reconstruct HEX with your variables, but omit the last variable if it’s value equals 20.
Might be a faster way though but this would get it done.
This reply was modified 3 years, 6 months ago by msepsis.
OK, I have been trying to make this work and I found this:
-- trim whitespace from right end of string
return s:find'^%s*$' and '' or s:match'^(.*%S)'
I’m guessing this is related to the String Class Atom made reference to. This is how I got it to work in my method:
nameData = L(PatchLabel:getProperty("uiLabelText"))
function trim (s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
nameTrim = (trim(nameData))
fileToWrite = utils.saveFileWindow("Save patch to disk", File(nameTrim), "*.syx", true)