<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Casting in ivyScript</title><link>https://answers.axonivy.com/questions/341/casting-in-ivyscript</link><description>&lt;p&gt;I need to call a method on certain componentes within a rich dialog panel. I get all components of the panel and then loop over them like this: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;List&amp;lt;ULCComponent&amp;gt; listComponent = panel.getComponents();
for(int i = 0; i &amp;lt; listComponent.size(); i++){
    if(listComponent.get(i) instanceof RLabel){
        RLabel label = (RLabel) listComponent.get(i);
        ((RLabel) listComponent.get(i)).setVisible(in.showLabel);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In both lines with the casting I get exceptions:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Unexpected token: identifier 'listComponent'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What is wrong?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/341/casting-in-ivyscript" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 13 Sep 2018 08:07:13 -0400</lastBuildDate><item><title>Answer by Roland Strobl</title><link>https://answers.axonivy.com/questions/341/casting-in-ivyscript/3420</link><description>&lt;p&gt;Yeah, programmers ... Had the same issue. Basically it drills down to RTFM. It is properly documented in the designer users guide (V 7.1) under &lt;strong&gt;IvyScript Reference, Operators, "Type cast operator"&lt;/strong&gt;. I ended up writing helper classes to do the job. What a waste of time ... now to be refactored.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Roland Strobl</dc:creator><pubDate>Thu, 13 Sep 2018 08:07:13 -0400</pubDate><guid>https://answers.axonivy.com/questions/341/casting-in-ivyscript/3420</guid></item><item><title>Answer by Benedict Groppe</title><link>https://answers.axonivy.com/questions/341/casting-in-ivyscript/342</link><description>&lt;p&gt;The normal Java casting &lt;/p&gt;
&lt;p&gt;&lt;code&gt;(RLabel) panel.getComponents(i)&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;does not work in ivyScript. You have to use &lt;/p&gt;
&lt;p&gt;&lt;code&gt;panel.getComponents(i) AS RLabel&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;then it should work. Do not forget to import RLabel.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Benedict Groppe</dc:creator><pubDate>Fri, 19 Mar 2010 03:41:02 -0400</pubDate><guid>https://answers.axonivy.com/questions/341/casting-in-ivyscript/342</guid></item></channel></rss>