{"id":154,"date":"2023-12-20T15:45:52","date_gmt":"2023-12-20T15:45:52","guid":{"rendered":"https:\/\/xojo.itbib4you.be\/?page_id=154"},"modified":"2023-12-22T15:15:25","modified_gmt":"2023-12-22T15:15:25","slug":"xojo-fundamentals","status":"publish","type":"page","link":"https:\/\/xojo.itbib4you.be\/index.php\/xojo-fundamentals\/","title":{"rendered":"Xojo Fundamentals"},"content":{"rendered":"\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-width wp-block-button__width-25 has-custom-font-size has-small-font-size\"><a class=\"wp-block-button__link has-light-green-cyan-to-vivid-green-cyan-gradient-background has-background wp-element-button\" href=\"https:\/\/xojo.itbib4you.be\/\">Overview<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>To introduce the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Xojo<\/mark> language, the main features of the language are summarised in this lesson. This lesson should allow the user to add simple code to <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Event Handlers<\/mark> .<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Variables<\/h2>\n\n\n\n<p>Xojo is a strongly typed language: variables must be declared before they can be used. The syntax to declare a variable is as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-yellow-background-color has-background\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> variable name <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As data type<\/mark><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Variable names<\/h3>\n\n\n\n<p>The following rules apply to naming a variable:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Variable names must always start with a letter;<\/li>\n\n\n\n<li>Variable names may contain letters, numbers and some special characters (for instance underscore (_));<\/li>\n\n\n\n<li>Variable names in Xojo are <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">case-insensitive<\/mark> (FirstName, firstname and FIRSTNAME refer to the same variable).<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted has-yellow-background-color has-background\">Use <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">camel case<\/mark> (first letter is lowercase, subsequent words in the name start with a capital letter) to name variables (for instance firstName)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Data types<\/h3>\n\n\n\n<p>The following data types are frequently used:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular has-small-font-size\"><table><thead><tr><th>Data type<\/th><th>Description<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td>Integer<\/td><td>Integer variables contain whole numbers<\/td><td><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> score <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark><br>score = 15<\/td><\/tr><tr><td>Double<\/td><td>Double variables contain decimal numbers<\/td><td><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> salary <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Double<\/mark><br>salary = 4567.87<\/td><\/tr><tr><td>Currency<\/td><td>Fixed-decimal: mainly used for calculations with monetary data<\/td><td><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> bankBalance <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Currency<\/mark><br>bankBalance = 123678.78<\/td><\/tr><tr><td>String<\/td><td>String variables contain a series of characters<\/td><td><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> myName <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As String<\/mark><br>myName = &#8220;John&#8221;<\/td><\/tr><tr><td>Boolean<\/td><td>Boolean variables are limited to the values True or False<\/td><td><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> invoicePaid <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Boolean<\/mark><br>invoicePaid = True<\/td><\/tr><tr><td>Color<\/td><td>Color variables contain color values<\/td><td><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> highlight <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Color<\/mark><br>highlight = <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Color<\/mark>.Red<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Data types<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Mathematical operations<\/h3>\n\n\n\n<p>The following operators are used frequently:<\/p>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">Operator<\/th><th>Operation<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">+<\/td><td>Addition<\/td><td>5 + 7 = 12<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">&#8211;<\/td><td>Subtraction<\/td><td>12 &#8211; 5 = 7<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">*<\/td><td>Multiplication<\/td><td>5 * 3 = 15<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">\/<\/td><td>Division<\/td><td>22 \/ 4 = 5.5<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">^<\/td><td>Exponentiation<\/td><td>3 ^ 3 = 27<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Mathematical operators<\/figcaption><\/figure>\n\n\n\n<p>Complex mathematical expressions are evaluated using the following priority rules (evaluated from left to right):<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Parenthesis;<\/li>\n\n\n\n<li>Exponentiation;<\/li>\n\n\n\n<li>Multiplication and division;<\/li>\n\n\n\n<li>Addition and subtraction.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">String operations<\/h3>\n\n\n\n<p>The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">+<\/mark> operator can be used to combine (<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">concatenate<\/mark>) strings: <\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular has-small-font-size\"><table><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">Operator<\/th><th>Operation<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">+<\/td><td>Concatenation of strings<\/td><td>&#8220;Napoleon &#8221; + &#8220;Bonaparte&#8221; = &#8220;Napoleon Bonaparte&#8221;<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">String operator<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Arrays<\/h2>\n\n\n\n<p>An <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">array<\/mark> is a collection of data for a specific data type. An element in an array is accessible through its <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">index<\/mark>. The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">index<\/mark> of the first element is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">zero<\/mark> (<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">0<\/mark>). <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Arrays<\/mark> can be defined as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-yellow-background-color has-background\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> arrayName() <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As dataType<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> arrayName(size1[,size2, size3...]) <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As dataType<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> arrayName <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As dataType<\/mark> = <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Array<\/mark>(value1, value2...)<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-light-gray-background-color has-background has-small-font-size\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Examples:<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> months() <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As String<\/mark>\nmonths.Add(<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">\"January\"<\/mark>)\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> months(12) As <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">String<\/mark>\nmonths(0) = <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">\"January\"<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> months() <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As String<\/mark> = <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Array<\/mark>(<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">\"January\"<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">\"February\"<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">\"March\"<\/mark>)<\/pre>\n\n\n\n<p>The following methods are very useful when editing arrays:<\/p>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th>Method<\/th><th>Description<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td>Add<\/td><td>Adds a new element at the end of the array<\/td><td>months.Add(&#8220;January&#8221;)<\/td><\/tr><tr><td>AddAt<\/td><td>Adds a new element at the specified index<\/td><td>months.AddAt(2,&#8221;March&#8221;)<\/td><\/tr><tr><td>Count<\/td><td>Returns the number of elements in an array<\/td><td>numberElements = months.Count<\/td><\/tr><tr><td>FirstIndex<\/td><td>Returns index of the first element<\/td><td>first = months.FirstIndex<\/td><\/tr><tr><td>LastIndex<\/td><td>Returns index of the last element<\/td><td>last = months.LastIndex<\/td><\/tr><tr><td>RemoveAll<\/td><td>Removes all elements<\/td><td>months.RemoveAll<\/td><\/tr><tr><td>RemoveAt<\/td><td>Removes the element at the specified index<\/td><td>months.RemoveAt(2)<\/td><\/tr><tr><td>Sort<\/td><td>Sorts the array in ascending order<\/td><td>months.Sort<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Array methods<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Assignment statements<\/h2>\n\n\n\n<p>The assignment operator in Xojo is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">=<\/mark>. A variable to the left of the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">= <\/mark>sign gets a value from the right side of the statement. The value on the right side of the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">=<\/mark> sign can be a constant, a variable or an expression.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-yellow-background-color has-background\" style=\"line-height:1.4\">variable = constant|variable|expression<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-light-gray-background-color has-background has-small-font-size\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Examples:<\/mark>\n\nage = 12\nmyAge = yourAge\ntotalPrice = netPrice + salesTax<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Selection statements<\/h2>\n\n\n\n<p>A <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">selection statement<\/mark> will select one or more other statements based on the evaluation of a <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">condition<\/mark>. There are two selection statements available in Xojo: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">If&#8230;Then&#8230;Else<\/mark> and <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Select&#8230;Case<\/mark>.<\/p>\n\n\n\n<p>A conditional expression evaluates whether a relation between two values is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True<\/mark> or <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">False<\/mark>. In most cases, <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">relational operators<\/mark> will be used to define a condition. Xojo defines the following relational operators:<\/p>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">Operator<\/th><th>Definition<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">=<\/td><td>Equal<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">&gt;<\/td><td>Greater than<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">&gt;=<\/td><td>Greater than or equal to<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">&lt;<\/td><td>Less than<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">&lt;=<\/td><td>Less than or equal to<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">&lt;&gt;<\/td><td>Not equal<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Relational operators<\/figcaption><\/figure>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Logical operators<\/mark> can be used to combine two conditional expressions into one logical expression:<\/p>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">Operator<\/th><th>Definition<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">And<\/td><td>AND (<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True<\/mark> if <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">both<\/mark> conditions are <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True<\/mark>)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">Or<\/td><td>OR (<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True<\/mark> if <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">any<\/mark> condition is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True<\/mark>)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">Not<\/td><td>Not (inverts the result of a logical expression &#8211; If&nbsp;expression&nbsp;evaluates to&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True<\/mark>,&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Not<\/mark> returns&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">False<\/mark>. If&nbsp;expression&nbsp;evaluates to&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">False<\/mark>,&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Not<\/mark> returns&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True<\/mark>.)<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Logical operators<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">If&#8230;Then&#8230;Else<\/h3>\n\n\n\n<p>The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">If&#8230;Then&#8230;Else<\/mark> statement has the following syntax:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-yellow-background-color has-background\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">If<\/mark> conditional expression1 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Then<\/mark>\n   statement(s)\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">ElseIf<\/mark> conditional expression2 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Then<\/mark>\n   statements(s)\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">ElseIf<\/mark> conditional expression3 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Then<\/mark>\n   ...\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Else<\/mark>\n   statement(s)\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">End If<\/mark><\/pre>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">ElseIf <\/mark>and <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Else<\/mark> statements are optional. If the first conditional expression is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True <\/mark>then the statements following the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Then<\/mark> keyword are executed. If the first conditional expression is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">False<\/mark> then the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">ElseIf<\/mark> condition (if present) will be evaluated. If <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">none<\/mark> of the conditional expressions are <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True<\/mark> then the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Else <\/mark>statements (if present) will be executed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-light-gray-background-color has-background has-small-font-size\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Example:<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> discountCode <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark>\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> discount <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">If<\/mark> discountCode = 1 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Then<\/mark>\n   discount = 5\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">ElseIf<\/mark> discountCode = 2\n   discount = 10\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Else<\/mark>\n   discount = 0\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">End If<\/mark><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Select&#8230;Case<\/h3>\n\n\n\n<p>The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Select&#8230;Case<\/mark> statement tests a variable for a possible value. When the variable matches one of the values \u200b\u200blisted in a <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Case<\/mark>, the code following that <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Case<\/mark> keyword is executed. The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Else<\/mark> sentence (no match was found) is optional.<\/p>\n\n\n\n<p>The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Select&#8230;Case<\/mark> statement has the following syntax:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-yellow-background-color has-background\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Select Case<\/mark> variable\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Case<\/mark> value1\n   statement(s)\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Case<\/mark> value2\n   statement(s)\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Case<\/mark> value3\n   ...\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Else<\/mark>\n   statement(s)\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">End Select<\/mark><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-light-gray-background-color has-background has-small-font-size\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Example:<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> discountCode <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark>\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> discount <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Select Case<\/mark> discountCode\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Case<\/mark> 1\n   discount = 5\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Case<\/mark> 2\n   discount = 10\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Else<\/mark>\n   discount = 0\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">End Select<\/mark><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Iteration statements<\/h2>\n\n\n\n<p>Xojo has three statements to execute one or more lines of code multiple times: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">For&#8230;Next<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">While&#8230;Wend<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Do&#8230;Loop<\/mark>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">For&#8230;Next<\/h3>\n\n\n\n<p>A <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">For&#8230;Next <\/mark>statement is useful when you know how many times the iteration must run. The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">For&#8230;Next<\/mark> has the following syntax:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-yellow-background-color has-background\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">For<\/mark> variable = startValue <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">To<\/mark> endValue <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Step<\/mark> stepValue\n   statement(s)\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Next<\/mark><\/pre>\n\n\n\n<p>The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Step<\/mark> clause is optional. <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">startValue<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">endValue<\/mark> and <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">stepValue<\/mark> can be a constant or a variable.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-light-gray-background-color has-background has-small-font-size\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Example:<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> counter<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark>\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var <\/mark>sum <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark> = 0\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">For<\/mark> counter = 1 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">To<\/mark> 10 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Step<\/mark> 1\n   sum = sum + counter\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Next<\/mark><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">While&#8230;Wend<\/h3>\n\n\n\n<p>A <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">While&#8230;Wend<\/mark> statement will run the lines of code between the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">While<\/mark> and the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Wend<\/mark> sentences <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">as long as<\/mark> the conditional expression evaluates to <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True<\/mark>. If the condition evaluates to <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">False<\/mark> the execution will continue with the code after the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Wend<\/mark> sentence. If the condition is already <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">False<\/mark> at the start of the iteration then the iteration instructions will not be executed. The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">While&#8230;Wend<\/mark> statement has the following syntax:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-yellow-background-color has-background\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">While<\/mark> conditional expression \n   statement(s)\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Wend<\/mark><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-light-gray-background-color has-background has-small-font-size\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Example:<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> counter<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark> = 1\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var <\/mark>sum <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark> = 0\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">While<\/mark> counter &lt;= 10\n   sum = sum + counter\n   counter = counter + 1\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Wend<\/mark><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Do&#8230;Loop<\/h3>\n\n\n\n<p>The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Do&#8230;Loop<\/mark> statement will execute all lines of code between the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Do<\/mark> and the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Loop<\/mark> keywords <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">until<\/mark> the condition evaluates to <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">True<\/mark>. The conditional expression can either be at the beginning or at the end of the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Do&#8230;Loop<\/mark>. The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Do&#8230;Loop<\/mark> statement has the following syntax:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-yellow-background-color has-background\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Do Until<\/mark> conditional expression\n   statement(s)\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Loop<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Or<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Do<\/mark>\n   statement(s)\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Loop Until<\/mark> conditional expression<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-light-gray-background-color has-background has-small-font-size\" style=\"line-height:1.4\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-red-color\">Example:<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var<\/mark> counter<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark> = 1\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Var <\/mark>sum <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">As Integer<\/mark> = 0\n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Do Until<\/mark> counter > 10\n   sum = sum + counter\n   counter = counter + 1\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-bright-blue-color\">Loop<\/mark><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Introduction To introduce the Xojo language, the main features of the language are summarised in this lesson. This lesson should allow the user to add simple code to Event Handlers . Variables Xojo is a strongly typed language: variables must be declared before they can be used. The syntax to declare a variable is as &hellip; <a href=\"https:\/\/xojo.itbib4you.be\/index.php\/xojo-fundamentals\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Xojo Fundamentals&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-154","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/xojo.itbib4you.be\/index.php\/wp-json\/wp\/v2\/pages\/154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xojo.itbib4you.be\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/xojo.itbib4you.be\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/xojo.itbib4you.be\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xojo.itbib4you.be\/index.php\/wp-json\/wp\/v2\/comments?post=154"}],"version-history":[{"count":57,"href":"https:\/\/xojo.itbib4you.be\/index.php\/wp-json\/wp\/v2\/pages\/154\/revisions"}],"predecessor-version":[{"id":223,"href":"https:\/\/xojo.itbib4you.be\/index.php\/wp-json\/wp\/v2\/pages\/154\/revisions\/223"}],"wp:attachment":[{"href":"https:\/\/xojo.itbib4you.be\/index.php\/wp-json\/wp\/v2\/media?parent=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}