<br>Jerry, James and Martin:<br><br>Adam and I thank you all ... a lot  We are now 100% operational using 1 USB stick to update all versions of XO.  We will add some more exception handling and 1.75 specifics to the procedures once we return to Canada, but the combination of OOB 4.1 and the olpc.fth boot are making the frequent process of updating/enhancing things while here in Kenya just fly!!!<br>
<br>Cheers,<br><br>KG<br><div class="gmail_quote">On Tue, Jun 12, 2012 at 8:00 PM, James Cameron <span dir="ltr"><<a href="mailto:quozl@laptop.org" target="_blank">quozl@laptop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, Jun 12, 2012 at 11:08:29AM -0400, Kevin Gordon wrote:<br>
> Disclaimer:  Newbie Forth question ....:-)<br>
<br>
</div>Always welcome.<br>
<div class="im"><br>
> We are trying to create a consolidated unsecured update stick.<br>
<br>
</div>I worked on a secured update drive last week, so the techniques are on<br>
my mind.<br>
<br>
> [...]<br>
<div class="im">> So for those coming from a non-Forth background, we have hit a road<br>
> block. Is there perhaps a way to store a 'possible' command into a<br>
> variable then execute that 'variable' as a command, thereby perhaps<br>
> bypassing any of the apparent syntax error checking?  Unexpected<br>
> end-of-line is the most common result from attempting to call within<br>
> an if statement.  Or, we get copy-nand? on the 1.5 or fs-update? on<br>
> the 1.0 when the command exists in the source - whether it will<br>
> actually get 'called' or not ,based on the variable containing the<br>
> machine type..<br>
<br>
</div>evaluate or eval is a word that expects a string descriptor on the<br>
stack, and then executes the string as if it were typed.<br>
<br>
: eval  ( adr len -- )  ...  ;<br>
<br>
For example:<br>
<br>
        ok " 8 ." eval<br>
        8<br>
        ok<br>
<br>
or<br>
<br>
        : install-xo-1  " copy-nand u:\fs.img"  eval  ;<br>
<br>
The string can be assembled from pieces rather than from literals.<br>
You may find an example of that in the power log collector on the<br>
wiki, which assembles filenames.<br>
<br>
If there is a possibility that the evaluated command may fail, you<br>
should catch the exception and handle it.  Use catch for that.<br>
<br>
Good reference for catch and throw:<br>
<a href="http://www.complang.tuwien.ac.at/anton/euroforth/ef98/milendorf98.pdf" target="_blank">http://www.complang.tuwien.ac.at/anton/euroforth/ef98/milendorf98.pdf</a><br>
<br>
For example:<br>
<br>
: install-xo-1<br>
   " copy-nand u:\fs.img"      ( adr len )<br>
   ['] eval                    ( adr len 'eval )<br>
   catch                       ( ??? ??? exception# | 0 )<br>
   if                          ( ??? ??? )<br>
      2drop                    ( )<br>
      ." copy-nand failed, press any key" key drop<br>
   then                        ( )<br>
;<br>
<br>
You might also place the exception handler higher up.<br>
<br>
We also have $fs-update in later XO-1.5 and XO-1.75 versions, so that<br>
eval is not needed.  There is no $copy-nand .<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
James Cameron<br>
<a href="http://quozl.linux.org.au/" target="_blank">http://quozl.linux.org.au/</a><br>
</font></span></blockquote></div><br>