%%v:varibaleName%% %%v:variableId%%

Posted on
Fri Aug 26, 2016 6:49 pm
kw123 offline
User avatar
Posts: 5519
Joined: May 12, 2013
Location: Dallas, TX

%%v:varibaleName%% %%v:variableId%%

the attached can be used to convert %%v .... %% using variable name or variable ID and you can add text before and after.

Code: Select all
    def convertVariableText(self,textIn):
        #  converts eg:
        #"abc%%v:VariName%%xyz"   to abcCONTENTSOFVARIABLExyz
        #"abc%%V:VariNumber%%xyz to abcCONTENTSOFVARIABLExyz
        try:
            start= textIn.find("%%v:")
        except:
            return textIn
       
        if start==-1:
            return textIn
        textOut= textIn[start+4:]
        end = textOut.find("%%")
        if end ==-1:
            return textIn
        var = textOut[:end]
        try:
            vText= indigo.variables[int(var)].value
        except:
            try:
                vText= indigo.variables[var].value
            except:
                return textIn

        try:
            if end+2 >= len(textOut)-1:
                textOut= textIn[:start]+vText
                return textOut
            textOut= textIn[:start]+vText+textOut[end+2:]
            return textOut
        except:
            return textIn
        return textIn

Posted on
Sat Aug 27, 2016 8:42 am
jay (support) offline
Site Admin
User avatar
Posts: 14257
Joined: Mar 19, 2008
Location: Austin, Texas

Re: %%v:varibaleName%% %%v:variableId%%

Or you can call the plugin base classes substitute() (does both), substituteVariable(), or substituteDeviceState() methods... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Aug 27, 2016 11:28 am
kw123 offline
User avatar
Posts: 5519
Joined: May 12, 2013
Location: Dallas, TX

Re: %%v:varibaleName%% %%v:variableId%%

My main question: Why don't I know about these?


Sent from my iPhone using Tapatalk

Posted on
Sat Aug 27, 2016 4:01 pm
jay (support) offline
Site Admin
User avatar
Posts: 14257
Joined: Mar 19, 2008
Location: Austin, Texas

Re: %%v:varibaleName%% %%v:variableId%%

kw123 wrote:
My main question: Why don't I know about these?


:D Don't know - it's in the plugin base class docs...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest

cron