Kodi Community Forum
Using variable in boolean expression - Printable Version

Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Skinning (https://forum.kodi.tv/forumdisplay.php?fid=12)
--- Thread: Using variable in boolean expression (/showthread.php?tid=354929)



Using variable in boolean expression - ipefix - 2020-06-02

hi everybody
I don't understand the following errors
Code:
2020-06-02 11:47:14.757 T:13016   ERROR: Misplaced [
2020-06-02 11:47:14.757 T:13016   ERROR: Error parsing boolean expression string.isempty($var[durationkod])
2020-06-02 11:47:14.794 T:13016   ERROR: Misplaced [
2020-06-02 11:47:14.794 T:13016   ERROR: Error parsing boolean expression !control.hasfocus(9000) + !string.isempty($var[fanartkod])
Thk a lot


RE: Using variable in boolean expression - wyrm - 2020-06-02

(2020-06-02, 11:53)ipefix Wrote: hi everybody
I don't understand the following errors
Code:
2020-06-02 11:47:14.757 T:13016   ERROR: Misplaced [
2020-06-02 11:47:14.757 T:13016   ERROR: Error parsing boolean expression string.isempty($var[durationkod])
2020-06-02 11:47:14.794 T:13016   ERROR: Misplaced [
2020-06-02 11:47:14.794 T:13016   ERROR: Error parsing boolean expression !control.hasfocus(9000) + !string.isempty($var[fanartkod])
Thk a lot
@ipefix , very short answer is because you can't use $VAR's in conditions. What exactly are you trying to achive? If we have an idea what you are trying to achieve we could probably come up with an alternative for you.

Wyrm (AppTV)


RE: Using variable in boolean expression - ipefix - 2020-06-03

(2020-06-02, 16:46)wyrm Wrote:
(2020-06-02, 11:53)ipefix Wrote:  
@ipefix , very short answer is because you can't use $VAR's in conditions. What exactly are you trying to achive? If we have an idea what you are trying to achieve we could probably come up with an alternative for you.

Wyrm (AppTV)
Ok , bad news
Here's what I'm trying to do
Code:
                <control type="group">
                    <width>115</width>
                    <visible>String.IsEmpty($VAR[durationkod])</visible>
                    <control type="label">
                        <width>115</width>
                        <height>60</height>
                        <align>center</align>
                        <aligny>center</aligny>
                        <label>$VAR[durationkod]</label>
                        <font>font_flag</font>
                    </control>
                </control>



RE: Using variable in boolean expression - wyrm - 2020-06-03

(2020-06-03, 08:01)ipefix Wrote:
(2020-06-02, 16:46)wyrm Wrote:
(2020-06-02, 11:53)ipefix Wrote:  
@ipefix , very short answer is because you can't use $VAR's in conditions. What exactly are you trying to achive? If we have an idea what you are trying to achieve we could probably come up with an alternative for you.

Wyrm (AppTV)  
Ok , bad news
Here's what I'm trying to do
Code:
                <control type="group">
                    <width>115</width>
                    <visible>String.IsEmpty($VAR[durationkod])</visible>
                    <control type="label">
                        <width>115</width>
                        <height>60</height>
                        <align>center</align>
                        <aligny>center</aligny>
                        <label>$VAR[durationkod]</label>
                        <font>font_flag</font>
                    </control>
                </control>
@ipefix ,

sorry sport was not quite what I meant. Meant what is the ultimate aim of your code using the $VAR. Will take a punt based on the code you provided above. If you want to show a duration string only if there is something to show, just use the label block above and forget about the rest of the code around it. If the $VAR is really empty it will display nothing anyway, if it is not empty it will display what $VAR has resolved to.  Just to be clear, you have written a variable block in your include file, haven’t you?

Maybe post your variable code for durationkod if the above does not help.

Wyrm (AppTV)


RE: Using variable in boolean expression - pkscout - 2020-06-04

You could look at expressions, but basically you'd have to duplicate most of the logic that generated the VAR so that the expression could evaluate to False if it the logic would have generated an empty VAR.


RE: Using variable in boolean expression - jurialmunkey - 2020-06-04

You can also check !String.IsEmpty(Control.GetLabel(12345))

However, I would only use this method if you're using a grouplist for automatic spacing of other controls or if there is a separate control that also needs to be hidden if the label is blank. Performance wise, control.getlabel() is expensive and I would only use it if absolutely necessary - otherwise much better just to leave label visible but blank.


<control type="label" id='12345'>
<width>115</width>
<height>60</height>
<align>center</align>
<aligny>center</aligny>
<label>$VAR[durationkod]</label>
<font>font_flag</font>
<visible>!String.IsEmpty(Control.GetLabel(12345))</visible>
</control>



RE: Using variable in boolean expression - ipefix - 2020-06-05

Thank you all, I will test your proposals


RE: Using variable in boolean expression - Atamans - 2020-06-05

I think it will work, but without $VAR [.....]
 
Code:
<visible>String.IsEmpty(durationkod)</visible>

<visible>!String.IsEmpty(durationkod)</visible>



This forum uses Lukasz Tkacz MyBB addons.