A little help with allegroserve ...

This is a discussion on A little help with allegroserve ... within the lisp forums in Programming Languages category; 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 ...

Go Back   Application Development Forum > Programming Languages > lisp

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-11-2007, 03:58 AM
dan.ms.chaos@gmail.com
Guest
 
Default A little help with allegroserve ...

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* lookup
then (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.

Reply With Quote
  #2  
Old 09-11-2007, 06:05 AM
Petter Gustad
Guest
 
Default Re: A little help with allegroserve ...

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* lookup
then (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?
Reply With Quote
  #3  
Old 09-11-2007, 11:31 AM
dan.ms.chaos@gmail.com
Guest
 
Default Re: A little help with allegroserve ...


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 ...


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 10:32 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.