You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdewebdev/kommander/examples/tutorial/strings.kmdr

207 lines
7.5 KiB

<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
<class>Form1</class>
<widget class="Dialog">
<property name="name">
<cstring>Form1</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>522</width>
<height>447</height>
</rect>
</property>
<property name="caption">
<string>String functions</string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string></string>
<string></string>
<string></string>
</stringlist>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="TextEdit" row="1" column="0">
<property name="name">
<cstring>TextEdit1</cstring>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="populationText">
<string>@Array.setValue(Bool, 1, yes)
@Array.setValue(Bool, 0, no)
&lt;h2&gt;Kommander string functions&lt;/h2&gt;
&lt;b&gt;Length:&lt;/b&gt; @String.length("@LineEdit1")&lt;br&gt;
&lt;b&gt;First 5 chars:&lt;/b&gt; @String.left("@LineEdit1", 5)&lt;br&gt;
&lt;b&gt;Last 5 chars:&lt;/b&gt; @String.right("@LineEdit1", 5)&lt;br&gt;
&lt;b&gt;Chars from 6th to 10th:&lt;/b&gt; @String.mid("@LineEdit1", 6, 5)&lt;br&gt;
&lt;b&gt;Remove spaces:&lt;/b&gt; @String.remove("@LineEdit1", " ")&lt;br&gt;
&lt;b&gt;Replace spaces with *&lt;/b&gt;: @String.tqreplace("@LineEdit1", " ", *)&lt;br&gt;
&lt;b&gt;Uppercase:&lt;/b&gt; @String.upper("@LineEdit1")&lt;br&gt;
&lt;b&gt;Lowercase:&lt;/b&gt; @String.lower("@LineEdit1")&lt;br&gt;
&lt;b&gt;Is a number?:&lt;/b&gt; @Array.value(Bool, @String.isNumber("@LineEdit1"))&lt;br&gt;
&lt;b&gt;Is empty?&lt;/b&gt; @Array.value(Bool, @String.isEmpty("@LineEdit1"))&lt;br&gt;
&lt;b&gt;Contains "Kommander"?:&lt;/b&gt; @String.tqcontains("@LineEdit1", "Kommander")&lt;br&gt;
&lt;b&gt;Position of "Kommander":&lt;/b&gt; @String.tqfind("@LineEdit1", "Kommander")&lt;br&gt;
&lt;b&gt;Compare with "Kommander":&lt;/b&gt;
@execBegin
if [ @String.compare("@LineEdit1", "Kommander") -lt 0 ];then
echo "Less than Kommander&lt;br&gt;"
elif [ @String.compare("@LineEdit1", "Kommander") -gt 0 ];then
echo "Greater than Kommander &lt;br&gt;"
elif [ @String.compare("@LineEdit1", "Kommander") -eq 0 ];then
echo "Equals Kommander &lt;br&gt;"
fi
@execEnd
&lt;b&gt;Case insensitive match with "Kommander":&lt;/b&gt;
@execBegin
if [ @String.compare(@String.lower("@LineEdit1"), "kommander") -eq 0 ];then
echo "Match found&lt;br&gt;"
else
echo "Match failed&lt;br&gt;"
fi
@execEnd</string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string></string>
</stringlist>
</property>
</widget>
<widget class=TQLAYOUTWIDGET_OBJECT_NAME_STRING row="0" column="0">
<property name="name">
<cstring>Layout1</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class=TQLABEL_OBJECT_NAME_STRING>
<property name="name">
<cstring>TextLabel1</cstring>
</property>
<property name="text">
<string>Enter str&amp;ing here:</string>
</property>
<property name="buddy" stdset="0">
<cstring>LineEdit1</cstring>
</property>
</widget>
<widget class="LineEdit">
<property name="name">
<cstring>LineEdit1</cstring>
</property>
<property name="text">
<string>I love Kommander!</string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@widgetText</string>
</stringlist>
</property>
</widget>
</hbox>
</widget>
<widget class=TQLAYOUTWIDGET_OBJECT_NAME_STRING row="2" column="0">
<property name="name">
<cstring>Layout2</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<spacer>
<property name="name">
<cstring>Spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="tqsizeHint">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
</spacer>
<widget class="ExecButton">
<property name="name">
<cstring>ExecButton1</cstring>
</property>
<property name="text">
<string>&amp;Test</string>
</property>
<property name="populationText">
<string></string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string></string>
</stringlist>
</property>
</widget>
<spacer>
<property name="name">
<cstring>Spacer2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="tqsizeHint">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
</spacer>
</hbox>
</widget>
</grid>
</widget>
<connections>
<connection>
<sender>ExecButton1</sender>
<signal>clicked()</signal>
<receiver>TextEdit1</receiver>
<slot>populate()</slot>
</connection>
</connections>
<tabstops>
<tabstop>LineEdit1</tabstop>
<tabstop>ExecButton1</tabstop>
<tabstop>TextEdit1</tabstop>
</tabstops>
<layoutdefaults spacing="6" margin="11"/>
</UI>