{"id":231,"date":"2020-08-06T12:55:49","date_gmt":"2020-08-06T11:55:49","guid":{"rendered":"http:\/\/www.qpcoaching.co.uk\/qedevelopment.co.uk\/?p=231"},"modified":"2020-12-30T15:18:30","modified_gmt":"2020-12-30T15:18:30","slug":"yocto-assignment","status":"publish","type":"post","link":"https:\/\/qedevelopment.co.uk\/?p=231","title":{"rendered":"Yocto: How to assign variables with examples"},"content":{"rendered":"\n<ul><li>= A hard assignment. The variable is assigned as soon as the statement is evaluated. If the assignment contains a reference to another variable then that reference will be included in the assignment rather that the value of the reference.<\/li><li>?= Defines a variable only if it is undefined at the time of parsing.<\/li><li>??= Assignment does not occur until the end of the parsing process.<\/li><li>:= Immediate variable expansion<\/li><li>+= Appending with spaces.<\/li><li>=+ Prepending with spaces.<\/li><li>.= Appending without spaces.<\/li><li>=. Prepending without spaces.<\/li><\/ul>\n\n\n\n<h2>Assignment Using Overrides<\/h2>\n\n\n\n<p>Variables can be appended or prepended using the override style syntax. In the example below B becomes equal to &#8220;bval additional data&#8221; and C becomes equal to &#8220;additional data cval&#8221;. Note that no additional spaces are include over what is in the original variable definitions.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">B = \"bval\"\nB_append = \" additional data\"\nC = \"cval\"\nC_prepend = \"additional data \"<\/pre>\n\n\n\n<p>Removal of data can also be accomplished. In the following example FOO becomes equal to &#8220;ghi abcdef&#8221;. Note that surrounding spaces are also removed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">FOO = \"abc def ghi abcdef abc def abc def\"\nFOO_remove = \"abc def\"<\/pre>\n\n\n\n<h2>Examples<\/h2>\n\n\n\n<p>In the following example the value of A is set to &#8220;aval&#8221;. The value of B is set to &#8220;pre${A}post&#8221;. In other words the value of B becomes dependent on the value of A at the times it is referenced. If the value of A changes between references to B the value of B will be different at those times.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">A = \"aval\"\nB = \"pre${A}post\"<\/pre>\n\n\n\n<p>The following code includes some immediate variable assignment. The value of A becomes &#8220;test 123&#8221; as the values of A and B are unassigned at the time of As assignment.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">T = \"123\"<br>A := \"${B} ${A} test ${T}\"<\/pre>\n\n\n\n<p>The following code uses a soft assignment. A is only assigned if the value is currently unassigned. The code therefore results in A being given the value of &#8220;one&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">A ?= \"one\"<br>A ?= \"two\"<\/pre>\n\n\n\n<p>The following code uses weak assignment. A is not assigned until the end of the parsing process and is therefore given a value of &#8220;two&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">A ??= \"one\"<br>A ??= \"two\"<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>= A hard assignment. The variable is assigned as soon as the statement is evaluated. If the assignment contains a reference to another variable then that reference will be included in the assignment rather that the value of the reference. ?= Defines a variable only if it is undefined at the time of parsing. ??= &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/qedevelopment.co.uk\/?p=231\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Yocto: How to assign variables with examples&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[20],"tags":[21],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/231"}],"collection":[{"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=231"}],"version-history":[{"count":12,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions"}],"predecessor-version":[{"id":369,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions\/369"}],"wp:attachment":[{"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}