Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import lx
import lxu.meta
class StringLength(lxu.meta.ChannelModifier):
def init_chan(self, desc):
desc.add ("input", lx.symbol.sTYPE_STRING)
desc.chmod_value (lx.symbol.fCHMOD_INPUT)
desc.add ("length", lx.symbol.sTYPE_INTEGER)
desc.chmod_value (lx.symbol.fCHMOD_OUTPUT)
def eval(self, chans):
string = chans.input.GetString()
if isinstance(string, str):
chans.length.SetInt(len(string))
else:
chans.length.SetInt(0)
chmod_meta = lxu.meta.Meta_ChannelModifier("cmStringLength", StringLength)
lxu.meta.MetaRoot(chmod_meta)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.