Using variable in boolean expression
#1
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
Reply
#2
(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)
Reply
#3
(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>
Reply
#4
(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)
Reply
#5
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.
Reply
#6
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.

xml:

<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>
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#7
Thank you all, I will test your proposals
Reply
#8
I think it will work, but without $VAR [.....]
 
Code:
<visible>String.IsEmpty(durationkod)</visible>

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

Logout Mark Read Team Forum Stats Members Help
Using variable in boolean expression0