[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do and read-line in MrEd.



Eli Barzilay <eli@barzilay.org> writes:

[snip]
> |   ;; read until "Content-Type..." is met
> |   (do ((line (read-line sin) (read-line sin)))
> |       ((not (regexp-match html-start line))))
> |         ^^^
> 
> Isn't this supposed to be the other way?

This fixed it, but I don't understand why.  Isn't the loop supposed to
execute until the test condition is false?  If so,
(regexp-match-html-line) by itself would be false on the first line,
so the loop should quit.

BTW, another minor issue that I wanted to ask about:

(define (grab-html b e)
  (define url (send urlbox get-value))
  (let-values ;;(((url) (send urlbox get-value))
   (((sin sout) (tcp-connect url 80))
    ((html-start) (regexp "Content-Type:.*")))

I don't want to make url global here.  I want to put it in the
let-values, as in:

(let-values
  (((url) (send urlbox get-value))
   ((sin sout) (tcp-connect url 80))
   ((html-start) (regexp "Content-Type:.*"))))

But this will not work since the call to tcp-connect does not see
url.  The most straight forward solution would be let-values* but that
apparently doesn't exist in MzScheme.
-- 
Jordan Katz <katz@underlevel.net>  |  Mind the gap