On Apr 13, 2012, at 11:33 AM, Roelof Wobben wrote:

> I have problems with place-image/align.
> 
> I have this : 
> 
> ; Editor -> Image
> ; Function which displays the struct on the screen into a image.
> (define (render verwerker)

Don't you also have a global variable named verwerker?  I find that having a 
function parameter with the same name as a global variable leads to a lot of 
confusion (students tend to think they're the same thing).

>   (place-image/align (beside (text(editor-pre verwerker) 11 "black") cursor 
> (text(editor-post verwerker) 11 "black")) 0 0 left center workspace ))
> 
> But now I get a message that left is out of context. 
> 
> But where do I put it then ?

Have you written an inventory of available expressions in your function?
I would start with

(define-struct editor [pre post])

(define verwerker <whatever you defined it as>)
(define cursor <whatever you defined it as>)
(define workspace <whatever you defined it as>)
...
(define (render current)
      ; current                             an editor
      ; (editor-pre current)        a string
      ; (editor-post current)       a string
      ; verwerker                         a fixed editor (i.e. it's the same 
every time "render" is called)
      ; (editor-pre verwerker)    a fixed string
      ; (editor-post verwerker)  a fixed string
      ; cursor                                a fixed image
      ; workspace                        a fixed image
      ; "black", "left", "right", "center"   fixed strings
      ; 11                                       a fixed number
      <insert actual function body here, using only expressions from the 
inventory>
      )

Now that we've done this, we can see why you got that error message: the 
variable name left isn't in the inventory.  The literal string "left" is in the 
inventory, but that's not what you said.

Writing down explicitly which of your inventory items are "fixed", i.e. the 
same every time "render" is called, will also help you figure out why it's 
sometimes producing wrong answers.
If EVERYTHING you use in the function body is "fixed", then the result will 
also be "fixed", i.e. you'll get the same answer every time -- almost certainly 
not what you want.  However, there may well be SOME things that you want to be 
the same every time, such as the color "black", the background scene workspace, 
the font size 11, etc.


Stephen Bloch
sbl...@adelphi.edu


____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to