Nicholas Pisca ran into an issue when tokenizing a string in MEL where it didn’t seem to remember the empty strings… so he authored a small function that would actually return empty strings. Read his solution for tokenizing in mel to remember empty strings.

I encountered a strange thing recently. Turns out when you tokenize a string (the act of splitting up consecutive letters by a delimiter) in MEL scripting, it doesn’t remember empty strings. This can be a problem when you need to have the same number of elements in an array, but it resizes to an arbitrary count.

For example, using the MEL tokenize command, the string “d,s,e,,,d” would be split into an array of only four elements {”d” “s” “e” “d”}. If you wanted to return the empty values, the method as it stands would not do this.

I’ve authored a small function that will return empty strings. In the aforementioned example, it would return {”d” “s” “e” “” “” “d”}. The command is called “RealTokenize.”

1 comment

  1. One quick comment about RealTokenize… It only uses single character delimitation. I forgot to mention that in the original article. For the most part, I only use single character delimiters, but for anyone interested in multi-characters, they’d have to revise the subroutine. 🙂

Comments are closed.