<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Scripting</title><link>https://sourceforge.net/p/snowmix/wiki/Scripting/</link><description>Recent changes to Scripting</description><atom:link href="https://sourceforge.net/p/snowmix/wiki/Scripting/feed" rel="self"/><language>en</language><lastBuildDate>Fri, 23 Jan 2015 15:49:44 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/snowmix/wiki/Scripting/feed" rel="self" type="application/rss+xml"/><item><title>Scripting modified by Peter Maersk-Moller</title><link>https://sourceforge.net/p/snowmix/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v8
+++ v9
@@ -5,8 +5,8 @@

 **Script examples.**
-- [Digital Counter](Script Example Digital Counter)
-- [Analogue Swiss Clock](Script Example Anlogue Clock)
+- Simple cripting example [Digital Counter](Script Example Digital Counter)
+- Advanced scripting example [Analogue Swiss Clock](Script Example Anlogue Clock)

 Command macros.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Maersk-Moller</dc:creator><pubDate>Fri, 23 Jan 2015 15:49:44 -0000</pubDate><guid>https://sourceforge.netd5fa65b568b6bd839b9c08b9819246f8f54a0481</guid></item><item><title>Scripting modified by Peter Maersk-Moller</title><link>https://sourceforge.net/p/snowmix/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v7
+++ v8
@@ -38,6 +38,8 @@
 The execution pointer can be reset to point at the first line of a macro using the command *command restart* as shown below:

         command restart SomeMacroName
+
+The command *command restart* will also reset any counters, if any, for *next* and *loop* commands possibly part of the macro being 'restarted'.

 To see which line the execution pointer for a macro is currently at, the following command can be used:

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Maersk-Moller</dc:creator><pubDate>Thu, 13 Nov 2014 00:24:08 -0000</pubDate><guid>https://sourceforge.net8111c530159f2d5e54c899cbd99bad979215d23a</guid></item><item><title>Scripting modified by Peter Maersk-Moller</title><link>https://sourceforge.net/p/snowmix/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v6
+++ v7
@@ -6,6 +6,7 @@

 **Script examples.**
 - [Digital Counter](Script Example Digital Counter)
+- [Analogue Swiss Clock](Script Example Anlogue Clock)

 Command macros.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Maersk-Moller</dc:creator><pubDate>Thu, 13 Nov 2014 00:21:32 -0000</pubDate><guid>https://sourceforge.net5d97d983bdb89f1630f1ab01193d44b694bdead2</guid></item><item><title>Scripting modified by Peter Maersk-Moller</title><link>https://sourceforge.net/p/snowmix/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v5
+++ v6
@@ -1,4 +1,4 @@
-Snowmix Scripting
+Beginners Guide to Snowmix Scripting
 =====

 Snowmix offers both basic scripting and [advanced scripting](Advanced Scripting). This page will present how to do basic scripting and it is recommended that the concepts for basic scripting is well understood before advanced scripting is undertaken.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Maersk-Moller</dc:creator><pubDate>Tue, 11 Nov 2014 22:34:07 -0000</pubDate><guid>https://sourceforge.net7f4ba8976cdebfd3c9c729578acb7089623b44fb</guid></item><item><title>Scripting modified by Peter Maersk-Moller</title><link>https://sourceforge.net/p/snowmix/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -160,3 +160,5 @@
       next 10
       loop
     command end
+
+Obviously, the command macro DisplayState4Feed1 needs to be included in the command macro set with the command *overlay pre* or *overlay finish* to ensure the script is called at framerate.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Maersk-Moller</dc:creator><pubDate>Tue, 11 Nov 2014 22:32:32 -0000</pubDate><guid>https://sourceforge.netfd22518a749127e8abf4de3f616cdf97a5369135</guid></item><item><title>Scripting modified by Peter Maersk-Moller</title><link>https://sourceforge.net/p/snowmix/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -137,22 +137,26 @@
 Conditional execution.
 -----

-The following conditional control commands are available within commands.
+Please see the *if, else, endif* section in the [reference manual for commands](Reference Command/) for details on conditional execution.

-                if &amp;lt;condition&amp;gt;
-                else
-                endif
-                goto &lt;label name=""&gt;
-                next [&amp;lt;number&amp;gt;]
-                label &lt;/label&gt;&lt;label name=""&gt;
-                loop [&amp;lt;number&amp;gt;]
+The following example shows a conditional execution where the state of feed is is shown as text and updated every 10 frames.

-                &amp;lt;condition&amp;gt; = ['!']&amp;lt;cond&amp;gt; [('||' | '&amp;amp;&amp;amp;') &amp;lt;condition&amp;gt;]
-                &amp;lt;cond&amp;gt;      = &amp;lt;feedstate&amp;gt; | &amp;lt;prevstate&amp;gt; | &amp;lt;exist&amp;gt;
-                &amp;lt;feedstate&amp;gt; = feedstate(&amp;lt;feed no=""&amp;gt;,&amp;lt;feed state=""&amp;gt;) |
-                &amp;lt;prevstate&amp;gt; = prevstate(&amp;lt;feed no=""&amp;gt;,&amp;lt;feed state=""&amp;gt;) |
-                &amp;lt;exist&amp;gt;     = exist(command,&lt;command name=""&gt;);
-                &amp;lt;feed no=""&amp;gt;   = 0....(2^32)-1
-                &amp;lt;feed state=""&amp;gt;= 'SETUP' | 'PENDING' | 'RUNNING' | 'STALLED' | 'DISCONNECTED'
-
-More to be developed.
+    command create DisplayState4Feed1
+      text string 0 Running
+      text string 1 Disconnected
+      text string 2 Stalled
+      text font 0 Sans Bold 12
+      if feedstate(1,STALLED)
+        text place 0 2 0 100 100 0 0 0 1.0
+      else
+        if feedstate(1,RUNNING)
+          text place 0 0 0 100 100 0 0 0 1.0
+        else
+          if feedstate(1,DISCONNECTED)
+            text place 0 1 0 100 100 0 0 0 1.0
+          endif
+        endif
+      endif
+      next 10
+      loop
+    command end
&lt;/command&gt;&lt;/label&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Maersk-Moller</dc:creator><pubDate>Tue, 11 Nov 2014 22:30:52 -0000</pubDate><guid>https://sourceforge.net790f171e1ca16da92e7e0b161ac4999f076ebc0a</guid></item><item><title>Scripting modified by Peter Maersk-Moller</title><link>https://sourceforge.net/p/snowmix/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -2,6 +2,11 @@
 =====

 Snowmix offers both basic scripting and [advanced scripting](Advanced Scripting). This page will present how to do basic scripting and it is recommended that the concepts for basic scripting is well understood before advanced scripting is undertaken.
+
+
+**Script examples.**
+- [Digital Counter](Script Example Digital Counter)
+

 Command macros.
 -----
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Maersk-Moller</dc:creator><pubDate>Tue, 11 Nov 2014 22:23:26 -0000</pubDate><guid>https://sourceforge.netd745146497b05b9b5d004c2684a584d60ca2d4bf</guid></item><item><title>Scripting modified by Peter Maersk-Moller</title><link>https://sourceforge.net/p/snowmix/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -7,7 +7,7 @@
 -----
 The fundamental concept behind the basic scripting is the definition and use of command macros. For additional reading on command macros beyond this page. please see the [reference manual on command macro related commands](Reference Command).

-Command macros are defined using the Snowmix command *command create \&lt;command name=""&gt;* with a name of the macro as argument. Every line of commands following this command, is added to the command macro created rather than executed until the command *command end* is given. If the command *command create* is given again with an already existing command macro, command lines until the command *command end* are added to the command macro. The following example creates a single command macro named MyFirstCommand:
+Command macros are defined using the Snowmix command **command create &amp;lt;command macro name&amp;gt;** with a name of the macro intended to create as argument. Every line of commands following this command, is added to the command macro created rather than executed until the command **command end** is given. If the command *command create* is given again with an already existing command macro name, command lines until the command **command end** are added to the specified command macro. The following example creates a single command macro named MyFirstCommand:

         command create MyFirstCommand
           text string Hello my friend
@@ -21,11 +21,35 @@

 The third thing to understand is that when executing a command macro containing another macro name as a command, that another macro is executed according to the same 3 conditions listed here and then the execution of the macro containing the another macro is continued until execution reach end of the macro or one of the two keywords *next* or *loop*.

-The following example deletes first the previous created command macro and then creates the 3 command macros MyFirstCommand, MySecondmacro and MyThirdExample:
+So execution of a command macro line by line continues including execution of command macros within the command macro until there or no more lines to execute or the execution reaches one of the two keywords *next* and *loop*.
+
+Next, loop and the execution pointer.
+-----
+When the *next* statement is identified while executing a command macro line by line, execution of the macro is suspended and the execution pointer of the macro is advanced to the line after the keyword *next*. Next time the command macro is executed, execution will continue from where the macros execution pointer points. If the *next* statement is followed by a positive integer N in the same line, the next statement is treated as if there were a N number of lines with the next statement.
+
+When the *loop* statement is identified while executing a command macro line by line, execution of the macro is suspended and the execution pointer of the macro is reset to point at the first line of the macro. Next time the command macro is executed, execution will continue from the beginning of the macro. If a macro does not end with a *loop* statement, the macro's execution pointer will eventually point beyond the last line. When that happends, additional call to the macro, effectively executing the macro, will have no effect. If the *loop* statement is followed by a positive integer N in the same line, the loop statement reset the command pointer to the first line N number of times. The next time the loop statement is reached, the loop statement is treated as if it was a *next* statement. Using that it is possible to loop for N first times the macro is called and then after that continue in the macro.
+
+The execution pointer can be reset to point at the first line of a macro using the command *command restart* as shown below:
+
+        command restart SomeMacroName
+
+To see which line the execution pointer for a macro is currently at, the following command can be used:
+
+        command pointer atline SomeMacroName
+
+To set the command line pointer at a specific line or after the last line, the following two commands can be used:
+
+        command pointer atline SomeMacroName 3
+        command afterend SomeMacroName
+
+
+Execution flow.
+-----
+The following example deletes first the previous created command macro and then creates the 3 new command macros MyFirstCommand, MySecondmacro and MyThirdExample:

         command delete MyFirstCommand
         command create MyFirstCommand
-          text string Hello my friend
+          text string 1 Hello my friend
           next
           MySecondmacro
           next
@@ -44,3 +68,86 @@
           loop
         command

+Initilly, the execution pointer for all 3 macros points at the first line of the macro. When the first command macro is executed, the following lines are executed:
+
+        MyFirstCommand
+          text string Hello my friend
+          next
+
+Now execution of the macro MyFirstCommand reaches the statement *next* in its second line the execution is suspended while its execution pointer is set to point to the third line. The result is that text string 1 is set to 'Hello my friend'.
+
+The next time the command macro MyFirstCommand is executed, execution happens from line 3 in the macro as shown below:
+
+        MyFirstCommand
+          MySecondmacro
+            text string 1 How is your day
+            text string 2 My day is fine
+            loop
+          next
+
+Now text string 1 is set to 'How is your day' and text string 2 is set to 'My day is fine'. Further more execution of macro MySecondmacro reaches a loop statement in its third line, so execution of that macro is suspended and its execution pointer is set to point to the first line of that macro. After that execution of the macro MyFirstCommand continues, but here the statement *next* is reached in its 4th line. Execution is now suspended and the execution pointer is set to line 5.
+
+The next time the command macro MyFirstCommand is executed, execution happens from line 5 in the macro as shown below:
+
+        MyFirstCommand
+          MyThirdExample
+            text string 1 What a wonderful weather
+            next
+          loop
+
+The 5th line of MyFirstCommand is a call to macro MyThirdExample so that macro gets executed. Doing so, the text string 1 is now set to 'What a wonderful weather' before reaching the *next* statement in the second line of MyThirdExample. This suspends the execution of macro MyThirdExample and the 6th line of the macro MyFirstCommand is executed. Here we reach a *loop* statement so execution of macro MyFirstCommand is suspended while its execution pointer is reset to point at the first line of the macro.
+
+The next time MyFirstCommand is called, line 1 and 2 of the macro is executed. The next time the macro is called, line 4 and 5 of the macro is executed. Executing line 4 will now result in executing line 1, 2 and 3 of the macro MySecondmacro and so on.
+
+
+Creating a macro within a macro.
+-----
+Snowmix does not support creating a macro within a macro as this would require the following to be valid:
+
+        command create MyFirstMacro
+          command create MySecondMacro
+            text string 1 some text
+          command end
+        command
+
+However when the first *command end* is detected, this signals the end of the definition of the macro MyFirstMacro and not the macro MySecondMacro that doesn't exist at this points. The second *command end* will result in a syntax error message safely to ignore. The result is the macro MyFirstMacro with the following content:
+
+        command create MySecondMacro
+        text string 1 some text
+
+However, even though this is not recommended, there is a workaround around this. Using the command *command addatline, it is possible to add the necessary *command end* as shown here:
+
+        command addatline MyFirstMacro 1 command end
+
+will result in in the macro MyFirstMacro containing the commands
+
+        command create MySecondMacro
+          text string 1 some text
+        command end
+
+and when the macro is called, it will create the macro MySecondMacro containing the line 'text string 1 some text'.
+
+          
+
+Conditional execution.
+-----
+
+The following conditional control commands are available within commands.
+
+                if &amp;lt;condition&amp;gt;
+                else
+                endif
+                goto &lt;label name=""&gt;
+                next [&amp;lt;number&amp;gt;]
+                label &lt;/label&gt;&lt;label name=""&gt;
+                loop [&amp;lt;number&amp;gt;]
+
+                &amp;lt;condition&amp;gt; = ['!']&amp;lt;cond&amp;gt; [('||' | '&amp;amp;&amp;amp;') &amp;lt;condition&amp;gt;]
+                &amp;lt;cond&amp;gt;      = &amp;lt;feedstate&amp;gt; | &amp;lt;prevstate&amp;gt; | &amp;lt;exist&amp;gt;
+                &amp;lt;feedstate&amp;gt; = feedstate(&amp;lt;feed no=""&amp;gt;,&amp;lt;feed state=""&amp;gt;) |
+                &amp;lt;prevstate&amp;gt; = prevstate(&amp;lt;feed no=""&amp;gt;,&amp;lt;feed state=""&amp;gt;) |
+                &amp;lt;exist&amp;gt;     = exist(command,&lt;/label&gt;&lt;/command&gt;&lt;command name=""&gt;);
+                &amp;lt;feed no=""&amp;gt;   = 0....(2^32)-1
+                &amp;lt;feed state=""&amp;gt;= 'SETUP' | 'PENDING' | 'RUNNING' | 'STALLED' | 'DISCONNECTED'
+
+More to be developed.
&lt;/command&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Maersk-Moller</dc:creator><pubDate>Mon, 10 Nov 2014 13:19:57 -0000</pubDate><guid>https://sourceforge.net68cdf8023862ca0f5fdc77ad4d8520b957f6504e</guid></item><item><title>Scripting modified by Peter Maersk-Moller</title><link>https://sourceforge.net/p/snowmix/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="snowmix-scripting"&gt;Snowmix Scripting&lt;/h1&gt;
&lt;p&gt;Snowmix offers both basic scripting and &lt;a class="" href="../Advanced%20Scripting"&gt;advanced scripting&lt;/a&gt;. This page will present how to do basic scripting and it is recommended that the concepts for basic scripting is well understood before advanced scripting is undertaken.&lt;/p&gt;
&lt;h2 id="command-macros"&gt;Command macros.&lt;/h2&gt;
&lt;p&gt;The fundamental concept behind the basic scripting is the definition and use of command macros. For additional reading on command macros beyond this page. please see the &lt;a class="" href="/p/snowmix/wiki/Reference%20Command"&gt;reference manual on command macro related commands&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Command macros are defined using the Snowmix command &lt;em&gt;command create \&amp;lt;command macro name&amp;gt;&lt;/em&gt; with a name of the macro as argument. Every line of commands following this command, is added to the command macro created rather than executed until the command &lt;em&gt;command end&lt;/em&gt; is given. If the command &lt;em&gt;command create&lt;/em&gt; is given again with an already existing command macro, command lines until the command &lt;em&gt;command end&lt;/em&gt; are added to the command macro. The following example creates a single command macro named MyFirstCommand:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;    &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="n"&gt;MyFirstCommand&lt;/span&gt;
      &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Hello&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt; &lt;span class="n"&gt;friend&lt;/span&gt;
      &lt;span class="n"&gt;loop&lt;/span&gt;
    &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now the first thing to understand is that every command macro has an individual execution pointer that points to the line to be executed the next time the command macro is executed.&lt;/p&gt;
&lt;p&gt;The next thing to understand is that when executing a command macro all lines in a macro is executed in line order from the line pointed to by the execution pointer until there is a line with the keywords &lt;em&gt;next&lt;/em&gt; or &lt;em&gt;loop&lt;/em&gt; or the execution pointer has reached the end of the command macro.&lt;/p&gt;
&lt;p&gt;The third thing to understand is that when executing a command macro containing another macro name as a command, that another macro is executed according to the same 3 conditions listed here and then the execution of the macro containing the another macro is continued until execution reach end of the macro or one of the two keywords &lt;em&gt;next&lt;/em&gt; or &lt;em&gt;loop&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The following example deletes first the previous created command macro and then creates the 3 command macros MyFirstCommand, MySecondmacro and MyThirdExample:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;    &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="n"&gt;delete&lt;/span&gt; &lt;span class="n"&gt;MyFirstCommand&lt;/span&gt;
    &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="n"&gt;MyFirstCommand&lt;/span&gt;
      &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Hello&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt; &lt;span class="n"&gt;friend&lt;/span&gt;
      &lt;span class="n"&gt;next&lt;/span&gt;
      &lt;span class="n"&gt;MySecondmacro&lt;/span&gt;
      &lt;span class="n"&gt;next&lt;/span&gt;
      &lt;span class="n"&gt;MyThirdExample&lt;/span&gt;
      &lt;span class="n"&gt;loop&lt;/span&gt;
    &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;
    &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="n"&gt;MySecondmacro&lt;/span&gt;
     &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;How&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt;
     &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="n"&gt;My&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;fine&lt;/span&gt;
     &lt;span class="n"&gt;loop&lt;/span&gt;
    &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;
    &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="n"&gt;MyThirdExample&lt;/span&gt;
      &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;What&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;wonderful&lt;/span&gt; &lt;span class="n"&gt;weather&lt;/span&gt;
      &lt;span class="n"&gt;next&lt;/span&gt;
      &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="n"&gt;Will&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="n"&gt;rain&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
      &lt;span class="n"&gt;loop&lt;/span&gt;
    &lt;span class="n"&gt;command&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Maersk-Moller</dc:creator><pubDate>Sun, 09 Nov 2014 17:46:43 -0000</pubDate><guid>https://sourceforge.net09b2e4a8886db656eb286c131340c90e5337e36d</guid></item></channel></rss>