[wxm] running demo with options



Hi Wolfgang,

> 1.
> This way each command resp. input is executed, the output immediatedly shown and stop.
> So every time I try to catch the output line with my mouse in a hurry to hide it
> contents.
> After discussion of the input with the class I show again the output clicking on it 
> .. then going to the next input ..
> If I have not overlooked something, here is my
> 1. Hint: there should be an option like demo("example.exm", hide),
>          that will as default NOT show all corresponding output lines.

I found a similar problem when I wanted to write a demo file for a
conference I'll give tomorrow monday (University of Santiago de
Compostela, "History of equations: from Babylon to Computer Algebra
Systems"  -- if you are interested :)

I'll run the demo in wxmaxima and I also want to have some control on
when computations should be made and displayed. An English translation
is attached. You'll see two menus:

(1:compute; 0:no computation) ...
  1 => computes the example
  0 => avoids computation (any other number is also admitted)
       and jumps to the next menu.


(0:next; n:example number; -1:end) ...
  0 => goes to next example
  n => goes to example number n (upwards and downwards)
 -1 => end of demo.

I hope you'll find useful hints here.

-- 
Mario Rodriguez Riotorto
www.biomates.net
-------------- next part --------------
/*

by Mario Rodriguez Riotorto
  2007, GPL License

*/


/* The audience shouldn't see some warnings */
eval_string("1+1")$
print("");
print("");
print("");
print("");
print("");
print("");
print("");
print("");
print("");

block([k:1, n:1, ec, ecuaciones],

  ecuaciones:
    [["solve(3*x=4)",
             ["This is a very simple equation"]],
     ["solve([a*x=4],[x])", 
             ["Equation with parameter"]],
     ["solve([a*x=4],[a])", 
             ["Now parameter is x"]],
     ["solve(x^2-19/7*x-6/5=0)", 
             ["Equation of degree two",
              "with numeric coefficients"]],
     ["solve([x^2-19/7*x-a=0],[x])", 
             ["Equation of degree two",
              "with parameter a "]],
     ["solve([x^2-19/7*x-a=0],[a])", 
             ["Equation of degree one",
              "with parameter x"]],
     ["solve(x^4+8*x^3+9*x^2+8*x+1/3)", 
             ["Polynomic equation",
              "of degree four"]],
     ["float(solve(x^4+8*x^3+9*x^2+8*x+1/3))", 
             ["Function 'float' gives you",
              "approximate solutions"]],
     ["solve(x^7+6*x^6+7*x^5+43*x^4+11*x^3+35*x+5)", 
             ["An equation of degree seven?"]],
     ["factor(x^7+6*x^6+7*x^5+43*x^4+11*x^3+35*x+5)", 
             ["Maxima factorizes and solves",
              "factors separately"]],
     ["solve(x^6+x^5+x^4+x^3+x^2+x+1=0)", 
             ["Here we arrive to the limits",
              "found by Abel and Galois"]],
     ["algsys([x^6+x^5+x^4+x^3+x^2+x+1=0],[x])", 
             ["But there are numeric methods"]],
     ["algsys([x*y=3, x-y=4/5], [x,y])", 
             ["A non linear system"]],
     ["(load(mnewton), mnewton([x*exp(x)-4*x-2], [x], [0]))", 
             ["'mnewton' is an additional package",
              "for the computation of",
              "non algebraic equations" ]],
     ["(load(draw), wxdraw2d(explicit(x*exp(x)-4*x-2, x, -3,3), grid=true))", 
             ["With additional package 'draw',",
              "you can plot functions and select",
              "new initial values for the Newton algorithm"]],
     ["mnewton([x*exp(x)-4*x-2], [x], [1])", 
             ["We call 'mnewton' again,",
              "but with a different",
              "initial value x=1"]],
     ["mnewton([x^3-2*x+1-y^2, x^3+y^3-3*x*y^2+x+1], [x, y], [2, 2])", 
             ["A system of equations",
              "to be solved by Newton"]]
    ],

  while k # -1 and n <= length(ecuaciones) do(
    ec: ecuaciones[n],
    print(""),print(""),print(""),
    print("---------- Example", n, "----------"),
    map(print, ec[2]),
    print("---"),print(""),
    print(ec[1]),
    k: read("(1:compute; 0:no computation) ..."),
    if (k=1) then print(eval_string(ec[1])),
    k: read("(0:next; n:example number; -1:end) ..."),
    if k>0
      then n: k
      else n: n+1 )) $