Language Syntax for Text Manipulation in dmx binding Statements

I have a variable called display_mode which I use to contol the visibility of various windows in my app. So it can have values such as:

app_contacts
app_finances
login_signup
login_login

For certain part of my app, I want to access the text section of display_mode which is before the underscore, so to find “app” or “login”.

So I’m looking for syntax along the lines of:

display_mode.text_before('_')

What syntax do I use for that?

Hey Antony,

Split by the underscore and then take the first item (index 0)

display_mode.value.split("_")[0]

–Ken

2 Likes

Thanks @mebeingken!

(note: it works better with the single quotes around the underscore!)

So what language is the split function… javascript or dmx-zone?

Well, the split option is available in the formatter options in the UI.
There is a split method available in JavaScript as well, but I’m not sure how is this related.

Hey @Teodor, I appreciate getting a reply on a Sunday evening! :pray:

I’ve had a good old play around, and I cannot work out how to get the split function via the UI… is there a tutorial or something on this? I’d prefer to use the UI if I can! :slight_smile:

Select the dynamic value, then click the formatter icon, then select text > split.

Oh yes, I have it now.

I find it a bit confusing, as by default, a variable is listed as type Object in that Data Formats menu… so yes, once set to Text, then it works with Transform -> Split.

A whole new world has opened up to me now… thanks @Teodor !

1 Like