Using a PARAM to Check a Boolean Condition
#1
Is this a valid use of a $PARAM?

I have a couple of buttons with visible conditions checking if a container HasNext or HasPrevious. If I hard-code the Container ID, everything works as expected.

Code:
<visible>Container($PARAM[list_id]).HasPrevious</visible>

When I attempt to use a $PARAM for any boolean condition, my Kodi.log idicates the following:
Code:
15:59:12.986 T:6012   ERROR: Misplaced [
15:59:12.986 T:6012   ERROR: Error parsing boolean expression Container($PARAM[list_id]).HasPrevious
15:59:12.986 T:6012   ERROR: Misplaced [
15:59:12.986 T:6012   ERROR: Error parsing boolean expression Container($PARAM[list_id]).HasNext

I am unable to find anything stating that this is not a valid use of PARAM. Additionally, it works for InfoLabels on the same Container.

Edit: I should mention I am attempting my testing on Kodi 17.1.
Reply
#2
you have to set the $PARAM
Code:
<include content="The Name Of The Include You Will Be Using">
<param name="list_id" value="9000"/>
</include>
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#3
It is set...

The log appears to be complaining about syntax.
Reply
#4
Not sure then ... maybe I should check my log to see if I have any of those hahahaha
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#5
It is also not working for me, so you would presumably know if the same was happening for you without the log.
Reply
#6
Works fine for me.

We might need to see more of your code to diagnose.

What's your code for calling the include?
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#7
It is being called from a template file for skinshortcuts, which I don't believe should have anything to do with the issue.

The includes file gets built with the following code:
Code:
<control id="9003" type="group">
    <visible>StringCompare(Container(9000).ListItem.Property(submenuVisibility),weather)</visible>
    <onup>20</onup>
    <ondown condition="System.HasAddon(script.globalsearch)">608</ondown>
    <ondown condition="!System.HasAddon(script.globalsearch)">603</ondown>
    <visible>!Window.IsVisible(Favourites)</visible>
    <animation delay="1000" effect="fade" time="300">WindowOpen</animation>
    <animation effect="fade" time="200">WindowClose</animation>
    <include>VisibleFadeEffect</include>
    <control type="group">
        <left>0</left>
        <top>12%</top>
        <include content="WeatherWidget">
            <param name="list_id" value="80111" />
        </include>
        <include content="WidgetArrows">
            <param name="list_id" value="80111" />
        </include>
    </control>
</control>

The WeatherWidget has the list I am trying to track:
Code:
<include name="WeatherWidget">
    <!--title label-->
    <control type="label">
        <centerleft>50%</centerleft>
        <top>0</top>
        <height>30</height>
        <width>810</width>
        <label>$INFO[Container(9000).ListItem.Property(widgetName)]</label>
        <align>center</align>
        <aligny>center</aligny>
        <font>breadcrumb.secondary</font>
        <textcolor>white</textcolor>
        <shadowcolor>button.nf</shadowcolor>
    </control>
    <!--content list-->
    <control type="list" id="$PARAM[list_id]">
    ...

The WidgetArrows has the visibility condition:
Code:
<include name="WidgetArrows">
    <param name="list_id" default="8011" />
    <definition>
        <!--arrows-->
        <control type="group">
            <!--left arrow bg-->
            <control type="button" id="80001">
                <left>380</left>
                <top>155</top>
                <width>50</width>
                <height>50</height>
                <texturefocus colordiffuse="$VAR[Colour.500]">backgrounds/white.png</texturefocus>
                <texturenofocus colordiffuse="tertiary">backgrounds/white.png</texturenofocus>
                <onclick>Control.Move($PARAM[list_id],-1)</onclick>
                <visible>Container($PARAM[list_id]).HasPrevious</visible>
                <include>VisibleFadeEffect</include>
            </control>
            <!--left arrow-->
            <control type="image">
                <left>380</left>
                <top>155</top>
                <width>50</width>
                <height>50</height>
                <texture colordiffuse="text.primary">arrow-big-left.png</texture>
                <visible>Control.IsVisible(80001) + !Control.HasFocus(80001)</visible>
            </control>
            <!--left arrow-->
            <control type="image">
                <left>380</left>
                <top>155</top>
                <width>50</width>
                <height>50</height>
                <texture colordiffuse="white">arrow-big-left.png</texture>
                <visible>Control.IsVisible(80001) + Control.HasFocus(80001)</visible>
            </control>
            <!--right arrow bg-->
            <control type="button" id="80002">
                <description>right Arrow</description>
                <left>1490</left>
                <top>155</top>
                <width>50</width>
                <height>50</height>
                <texturefocus colordiffuse="$VAR[Colour.500]">backgrounds/white.png</texturefocus>
                <texturenofocus colordiffuse="tertiary">backgrounds/white.png</texturenofocus>
                <onclick>Control.Move($PARAM[list_id],1)</onclick>
                <visible>Container($PARAM[list_id]).HasNext</visible>
                <include>VisibleFadeEffect</include>
            </control>
            <!--right arrow-->
            <control type="image">
                <left>1490</left>
                <top>155</top>
                <width>50</width>
                <height>50</height>
                <texture colordiffuse="text.primary">arrow-big-right.png</texture>
                <visible>Control.IsVisible(80002) + !Control.HasFocus(80002)</visible>
            </control>
            <!--right arrow-->
            <control type="image">
                <left>1490</left>
                <top>155</top>
                <width>50</width>
                <height>50</height>
                <texture colordiffuse="white">arrow-big-right.png</texture>
                <visible>Control.IsVisible(80002) + Control.HasFocus(80002)</visible>
            </control>
        </control>
    </definition>
</include>

An odd thing is that I seem to be able to get back any InfoLabel from the same container, such as Container($PARAM[list_id]).NumItems.

@smitchell6879 @jurialmunkey
Thanks to both of you for taking the time to try and help.
Reply
#8
I absolutely cannot see any reason why this shouldn't work and when I tested a simple piece of code passing the list_id param through to the same Container($PARAM[list_id]).HasPrevious condition it worked fine with no errors.

My only suggestion would be to remove all your <!-- comments --> from the include (e.g. remove <!--arrows--> etc.) and see if it works then. I have occasionally encountered issues with comments inside includes breaking them - I haven't noticed any real pattern to it, though I think it might be something to do with comments at the start of an include with a <definition> tag.

If that doesn't work, my other suggestion would be to pass the *whole* condition through as a param (though you really shouldn't have to do this as there is nothing technically wrong with your code as far as I can tell).
i.e.
<param name="condition_hasnext" value="Container(80111).HasNext" />
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#9
I can't even tell you how awesome you are! Removing comments caused it to start working as expected. Thank you for taking the time to look over the code and provide the solution!

I can't explain how aggravating it is to put the time into commenting code (even if I do it poorly), only to turn around and have that be the cause of a bug. I understand how tough it can be to start skinning on this engine, so I was attempting to try and make it easier for anyone following along with my code to understand what each section is doing.
Reply
#10
(2017-03-26, 06:39)Bumpaneer Wrote: I can't even tell you how awesome you are! Removing comments caused it to start working as expected. Thank you for taking the time to look over the code and provide the solution!

I can't explain how aggravating it is to put the time into commenting code (even if I do it poorly), only to turn around and have that be the cause of a bug. I understand how tough it can be to start skinning on this engine, so I was attempting to try and make it easier for anyone following along with my code to understand what each section is doing.
Yeah tell me about it! It is especially frustrating as I haven't figured out a pattern to it yet, so it makes it hard to report the bug.

You can use description tags e.g.
<control type="button" description="mycoolbutton">

But I find that far more annoying because its extra typing, plus it doesn't get the same syntax highlighting that makes comments standout in sublimetext or other text editors.
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#11
On a couple more tests, I think it might be includes with <definition> tags and if you put a comment at the start of a group control
e.g.

Code:
<definition>
    <control type="group">
         <!-- comment -->
         ...
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#12
I've been noticing this too, there's definitely something funky happening with / because of comments. Haven't figured out the exact pattern.

Example:I get code printed on screen with the code below. If I remove the comments everything is normal..

PHP Code:
<focusedlayout width="$PARAM[Width]height="$PARAM[ItemHeight]">
    <!--
0-->
    <
control type="image">
        <
width>$PARAM[Width]</width>
        <
height>$PARAM[ItemHeight]</height>
        <
texture colordiffuse="$VAR[color:Accent]">colorize/75.png</texture>
        <
animation type="Conditional" condition="$PARAM[FadeCondition]">
            <
effect type="Fade" start="100" end="25" time="150"/>
        </
animation>
        <
visible>$EXP[!IsContent]</visible>
    </
control>
    <!--
1-->
    <
control type="image">
        <
width>$PARAM[ListWidth]</width>
        <
height>$PARAM[ItemHeight]</height>
        <
texture colordiffuse="$VAR[color:Accent]">colorize/75.png</texture>
        <
animation type="Conditional" condition="$PARAM[FadeCondition]">
            <
effect type="Fade" start="100" end="25" time="150"/>
        </
animation>
        <
visible>$EXP[IsContent] + String.IsEqual(Skin.String(view.list.art),posters) + !Container.Content(actors)</visible>
    </
control>
    <!--
2-->
    <
control type="image">
        <
width>1040</width>
        <
height>$PARAM[ItemHeight]</height>
        <
texture colordiffuse="$VAR[color:Accent]">colorize/75.png</texture>
        <
animation type="Conditional" condition="$PARAM[FadeCondition]">
            <
effect type="Fade" start="100" end="25" time="150"/>
        </
animation>
        <
visible>$EXP[IsContent] + !String.IsEqual(Skin.String(view.list.art),posters) | Container.Content(actors)</visible>
    </
control
Reply
#13
(2017-03-26, 06:28)jurialmunkey Wrote: I absolutely cannot see any reason why this shouldn't work and when I tested a simple piece of code passing the list_id param through to the same Container($PARAM[list_id]).HasPrevious condition it worked fine with no errors.

My only suggestion would be to remove all your <!-- comments --> from the include (e.g. remove <!--arrows--> etc.) and see if it works then. I have occasionally encountered issues with comments inside includes breaking them - I haven't noticed any real pattern to it, though I think it might be something to do with comments at the start of an include with a <definition> tag.

If that doesn't work, my other suggestion would be to pass the *whole* condition through as a param (though you really shouldn't have to do this as there is nothing technically wrong with your code as far as I can tell).
i.e.
<param name="condition_hasnext" value="Container(80111).HasNext" />

i know the above is an old response but just wanted to thank @jurialmunkey for the contribution because it worked like a charm, i was getting the following log file errors but removing the comments i had made to the include(s), as jurialmunkey suggested, eliminated the errors completely... it was driving me crazy and googles searches came up empty, until i finally found this nugget, thanks again!

Code:
ERROR: Error parsing boolean expression Container($PARAM[focused])
ERROR: Misplaced [
Reply

Logout Mark Read Team Forum Stats Members Help
Using a PARAM to Check a Boolean Condition0