Hi
I want to store "metaPost" code in a database, e.g the following code:
numeric u, d, f[];
u = 1cm;
d = 0.1u;
vardef rotation( expr dir ) =
pair p;
if (xpart(dir)=1) : p := (0,1);
else: if (xpart(dir) = -1): p := (0,-1);
else: if (ypart(dir) = 1): p := (-1,0);
else: p := (1,0);
fi; fi; fi;
p
enddef;
def drawsquare( expr pos, size, dir, n, m ) =
draw pos--
pos + sizedir--
pos + size(dir + rotation( dir ))--
pos + size*(dir + rotation( dir ) + rotation( rotation( dir )))--
cycle;
enddef;
def fibonacci( expr n, m, pos, dir ) =
numeric size;
if (n <= m):
if (n = 0):
f0 := 1;
else: if (n = 1):
f1 := 1;
else:
f[n] := f[n-1] + f[n-2];
fi;fi;
size := d f[n];
drawsquare( pos, size, dir, n, m );
fibonacci( n+1, m, pos + size(dir + rotation( dir ) ), rotation( dir ) );
fi;
enddef;
beginfig( 0 );
pickup pencircle scaled 3pt;
fibonacci( 0, 11, (0,0), (0,-1) );
endfig;
end.
Now i need to put thsi in a mysql database( along with more others) and get the code back out looking the same as it was before it went in??. I`m using php/mysql. Any ideas on how to store it and retrieve it as it is and write to a file??
Please help this confused student
Thanks