| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| I'm experimenting with allegroserve , and I added this to examples.cl : (defun trans2 (z k) (if (eq (intern z) '|| ) '"" (let* ((a (char-code (coerce (subseq z 0 1 ) 'character ))) (Q (cond ( (or (> a 57) (= a 94) ) 2) ( (or (< a 46) (eq a 47)) 0) (T 1) )) (ze (cond ((or (= q 0 ) (= k 0)) '" ") ((= q k) '"" ) (T '" ") ))) ( concatenate 'string ze (subseq z 0 1) (trans2 (subseq z 1) q) )))) (publish ath "/experimental":content-type "text/html" :function #'(lambda (req ent) (let ((lookup (assoc "symbol" (request-query req) :test #'equal))) (with-http-response (req ent) (with-http-body (req ent) (html (:head (:title "DND")) ((:body ) "Compute trans2 of " ((:form :action "experimental" :method "get") ((:input :type "text" :maxlength 40 :size 20 :name "symbol"))) #+allegro ) (if* lookupthen (html :hr (:b "trans2") " of " ( rinc-safe (cdr lookup)) " is "( rinc-safe (trans2 (cdr lookup) 0) ):br :br)) :newline)))))) Trans2 itself worcks well , to get an ideea of what it does try (trans2 "(var+stuff*-(something-12.3))" 0) However the web page does not work as expected , the result is empty . Why does this happen ? Help please. |
|
#2
| |||
| |||
| dan.ms.chaos@gmail.com writes: > Why does this happen ? Help please. Haven't looked at your code in detail, but in general you can test the html generator macros using: (let ((lookup (cons 'symbol "(var+stuff*-(something-12.3))")) (*html-stream* *standard-output*)) (html (:head (:title "DND")) ((:body ) "Compute trans2 of " ((:form :action "experimental" :method "get") ((:input :type "text" :maxlength 40 :size 20 :name "symbol"))) ) (if* lookupthen (html :hr (:b "trans2") " of " ( rinc-safe (cdr lookup)) " is "( rinc-safe (trans2 (cdr lookup) 0) ):br :br)) :newline)) <head><title>DND</title></head><body>Compute trans2 of <form ACTION="experimental" METHOD="get"><input TYPE="text" MAXLENGTH=40 SIZE=20 NAME="symbol"></form><p></body><hr><b>trans2</b> of (var+stuff*-(something-12.3)) is ( var + stuff * - ( something - 12.3 ) )<br><br> You can also save the req and ent objects and test your your functions in the REPL. Great if you're running your Lisp under screen and connect with SLIME. Petter -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? |
|
#3
| |||
| |||
| Fixed that up . (defun trans2 (z k) (if (eq (length z) 0 ) ;replaced the (if (eq (intern z) '|| ) . '"" (let* ((a (char-code (coerce (subseq z 0 1 ) 'character ))) (Q (cond ( (or (> a 57) (= a 94) ) 2) ( (or (< a 46) (eq a 47)) 0) (T 1) )) (ze (cond ((or (= q 0 ) (= k 0)) '" ") ((= q k) '"" ) (T '" ") ))) ( concatenate 'string ze (subseq z 0 1) (trans2 (subseq z 1) q) )))) Seems this is a slightly different type of string or something ... |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.