<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.playonlinux.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Walkman</id>
		<title>PlayOnLinux - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.playonlinux.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Walkman"/>
		<link rel="alternate" type="text/html" href="https://wiki.playonlinux.com/index.php/Special:Contributions/Walkman"/>
		<updated>2026-05-07T02:04:45Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://wiki.playonlinux.com/index.php?title=Scripting_-_Chapter_4:_Conditions&amp;diff=877</id>
		<title>Scripting - Chapter 4: Conditions</title>
		<link rel="alternate" type="text/html" href="https://wiki.playonlinux.com/index.php?title=Scripting_-_Chapter_4:_Conditions&amp;diff=877"/>
				<updated>2016-07-08T21:58:44Z</updated>
		
		<summary type="html">&lt;p&gt;Walkman: Fixed example code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Conditions? Can one eat it? ==&lt;br /&gt;
&lt;br /&gt;
You&amp;#039;d have to be very hungry, but why not? More seriously, a condition will allow you to order your script to do different things according to &amp;#039;&amp;#039;&amp;#039;a test&amp;#039;&amp;#039;&amp;#039;. For example, the value of a variable.&lt;br /&gt;
&lt;br /&gt;
== Some examples will make it easier to understand ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A test, with no action taken in case of failure:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;playonlinux code&amp;quot;&amp;gt;&lt;br /&gt;
POL_SetupWindow_menu &amp;quot;What&amp;#039;s for dinner?&amp;quot; &amp;quot;Tonight&amp;#039;s menu&amp;quot; &amp;quot;Carrots Potatoes French-fries&amp;quot; &amp;quot; &amp;quot;&lt;br /&gt;
if [ &amp;quot;$APP_ANSWER&amp;quot; = &amp;quot;Carrots&amp;quot; ]&lt;br /&gt;
then&lt;br /&gt;
   POL_SetupWindow_message &amp;quot;Let&amp;#039;s eat&amp;quot; &amp;quot;Tonight&amp;#039;s menu&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The message &amp;quot;let&amp;#039;s eat&amp;quot; will only appear if the user chooses Carrots.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A test, with some action in case of failure:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;playonlinux code&amp;quot;&amp;gt;&lt;br /&gt;
POL_SetupWindow_menu &amp;quot;What&amp;#039;s for dinner?&amp;quot; &amp;quot;Tonight&amp;#039;s menu&amp;quot; &amp;quot;Carrots Potatoes French-fries&amp;quot; &amp;quot; &amp;quot;&lt;br /&gt;
if [ &amp;quot;$APP_ANSWER&amp;quot; = &amp;quot;Carrots&amp;quot; ]&lt;br /&gt;
then&lt;br /&gt;
   POL_SetupWindow_message &amp;quot;I&amp;#039;m on a hunger strike&amp;quot; &amp;quot;Tonight&amp;#039;s menu&amp;quot;&lt;br /&gt;
else&lt;br /&gt;
   POL_SetupWindow_message &amp;quot;Can I have a second helping?&amp;quot; &amp;quot;Tonight&amp;#039;s menu&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The message &amp;quot;I&amp;#039;m on a hunger strike&amp;quot; will only be displayed if the user chooses Carrots. Otherwise the message &amp;quot;Can I have a second helping?&amp;quot; will be displayed.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Threefold test, with no action in case of failure:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;playonlinux code&amp;quot;&amp;gt;&lt;br /&gt;
POL_SetupWindow_menu &amp;quot;What do you want to eat tonight?&amp;quot; &amp;quot;Tonight&amp;#039;s menu&amp;quot; &amp;quot;Carrots Potatoes French-fries&amp;quot; &amp;quot; &amp;quot;&lt;br /&gt;
if [ &amp;quot;$APP_ANSWER&amp;quot; = &amp;quot;French-fries&amp;quot; ]&lt;br /&gt;
then&lt;br /&gt;
    POL_SetupWindow_message &amp;quot;I love french fries&amp;quot; &amp;quot;Tonight&amp;#039;s menu&amp;quot;&lt;br /&gt;
elif [ &amp;quot;$APP_ANSWER&amp;quot; = &amp;quot;Potatoes&amp;quot; ]&lt;br /&gt;
then&lt;br /&gt;
    POL_SetupWindow_message &amp;quot;I agree to eat potatoes tonight&amp;quot; &amp;quot;Tonight&amp;#039;s menu&amp;quot;&lt;br /&gt;
elif [ &amp;quot;$APP_ANSWER&amp;quot; = &amp;quot;Carottes&amp;quot; ]&lt;br /&gt;
then&lt;br /&gt;
    POL_SetupWindow_message &amp;quot;I do not like carrots&amp;quot; &amp;quot;Tonight&amp;#039;s menu&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What this code does should be clear enough after seeing the previous examples.&lt;br /&gt;
&lt;br /&gt;
{{Info|In Bash, you can use either single-quotes (&amp;#039;), aka &amp;#039;&amp;#039;&amp;#039;apostrophe&amp;#039;&amp;#039;&amp;#039;, or double-quotes (&amp;quot;), aka &amp;#039;&amp;#039;&amp;#039;quote&amp;#039;&amp;#039;&amp;#039;. We highly recommend, as a standard, to use double-quotes (&amp;quot;), aka &amp;#039;&amp;#039;&amp;#039;quote&amp;#039;&amp;#039;&amp;#039;, so that you can use apostrophe in your string, if needed. Though, it is also preferred not to use contractions (which require an apostrophe, or &amp;#039;&amp;#039;&amp;#039;single-quote&amp;#039;&amp;#039;&amp;#039; (&amp;#039;)) at all to avoid this situation altogether. The choice is yours; choose whichever is the cleanest, easiest-to-read, most-concise code.}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Previous:&amp;#039;&amp;#039;&amp;#039; [[Scripting - Chapter 3: Variables|Chapter 3: Variables]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Next:&amp;#039;&amp;#039;&amp;#039; [[Scripting - Chapter 5: Wine|Chapter 5: Wine]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Walkman</name></author>	</entry>

	</feed>