It is nice to see RCaller has an higher usage rates after its 2.0 version.
You can see the embedded video in this entry. Have a nice training!
<?php
#!/usr/bin/fuzuli
#!/usr/bin/fuzuli (print "Content-type: text/html\n\n")
#!/usr/bin/fuzuli (print "Content-type: text/html\n\n") <?html <h1>Hello World!</h1> ?>
#!/usr/lib/fuzuli/fuzuli (print "Content-type: text/html\n\n") <?html <form method="get"> Enter your name: <input type="text" name="name"> <input type="text" name="email"> <input type="submit" value="Click"> </form> ?> (let name (REQUEST "name")) (let email (REQUEST "email")) (if (isset name) (print "Posted name is : " name) ) <?html <h1>-----------------</h1> ?> (if (isset email) (print "Posted email is: " email) )
#!/usr/lib/fuzuli/fuzuli (print "Content-type: text/html\n\n") <?html <table border = "1"> ?> (let days (list "sunday" "monday" "tuesday" "wednesday" "thursday" "friday" "saturday" ) ) (for (let i 0) (< i (length days)) (inc i) (block <?html <tr><td><b> ?> (print i) <?html </b></td> <td><i> ?> (print (nth days i)) <?html </b></td></tr> ?> ) ) <?html </table> ?>
setcookie (var "This is cookie value") (let value (getcookie "var"))
(require "/usr/lib/fuzuli/nfl/io.nfl")
(let f (fopen "/tmp/example.txt" "w")) (let liste (list 1 2 3 4 5 6 7 8 9 10 11 12 13 14)) (fwrite f liste) (fclose f)
(let dd (fopen "/tmp/example.txt" "r")) (let a 0) (let mysum 0) (for (let i 0) (< i 5) (inc i) (let mysum (+ mysum (fread dd a))) )
(def a INTEGER) (let dd (fopen "/tmp/kek.txt" "r")) (while (= (feof dd) 0) (block (print (fread dd a) " ") ) ) (fclose dd)
(let f (fopen "/tmp/example.txt" "w")) (let liste (list 1 2 3 4 5 6 7 8 9 10 11 12 13 14)) (fwrite f liste) (fflush f) (fclose f)
(let mydir (getpwd)) (print mydir "\n")
(chdir "/tmp")
(let mydir (dir ".")) (foreach direntry in mydir (block (print direntry "\n") ) )
(let mydir (dir ".")) (unlink "/tmp/example.txt") (rename "1.txt" "2.txt")
(function fibonacci (params x) (block (if (<= x 2) (return 1) (return (+ (fibonacci (- x 1)) (fibonacci (- x 2)))) ) ) )
(let result (fibonacci 5))
(let alist (: 1 10))
(for (let i 0) (< i 10) (inc i) (block (print "i is " i "\n") ) )
(def i INTEGER) (def d FLOAT) (def s STRING)
(block (def i INTEGER) (let i 10) ) (print i)
(def i INTEGER) (block (let i 10) ) (print i)
(let mathlib (dynload "FuzuliCore")) (let PI (C mathlib "pi") 0) (function sin (params x) (return (C mathlib "sind" x)) ) (function cos (params x) (return (C mathlib "cosd" x) ) ) (function tan (params x) (return (C mathlib "tand" x) ) )This package loads the dynamic library FuzuliCore (it is libFuzuliCore.so in Linux) and defines some math functions. Actually, they do nothing but acting like wrappers. The fuzuli function 'C' is used to call C functions from fuzuli. In example below, C functions pi, sin, cos and tan are wrapped. The sin and the cos functions are defined as
Token *sind(Token *params, Environment *env){ Token *resultToken = new Token(0.0, FLOAT); resultToken->setFloatValue(sin(params->tokens[0]->getFloatValue())); return(resultToken); } Token *cosd(Token *params, Environment *env){ Token *resultToken = new Token(0.0, FLOAT); resultToken->setFloatValue(cos(params->tokens[0]->getFloatValue())); return(resultToken); }
Token *sind(Token *params, Environment *env){ Token *resultToken = env->newToken(0.0, FLOAT); resultToken->setFloatValue(sin(params->tokens[0]->getFloatValue())); return(resultToken); }