user2329273
user2329273

Reputation: 63

Compatibility issue with drRacket: "require" and "frame"

I wonder if my drRacket has a problem : I see example on the internet of programs but when I put them in Dr racket, it considers them as an error.

It first append when I write (require racket/base) at the begining of a new file. It immediately consider it like an error. So I replace it with #lang racket/base and it was ok but it is strange, I still don't know why it doesn't work.

Then, I try to use this command : (define FRAME (new frame% [label "Graphic"] [width 500] [height 500])) but it show me a new error : new: unbound identifier in module in: new. This time I am unable to find something that work to show me my graphic :(

I dont't get it : why when I copy-past program that work on the net, they don't whant to whork whith me? It is really frustrating. I download the last version of the programme (version 5.3.3) and it does not solve my problem.

Anybody can explain it work with other person but it don't work with me? Or maybe tell me how to do my graphic?

Upvotes: 1

Views: 507

Answers (1)

uselpa
uselpa

Reputation: 18917

First I'd suggest you start every program with just

#lang racket

since this gives you the full base of the Racket language. Also make sure DrRacket is set to "determine language from source" (bottom left on Mac OS X).

Nevertheless some things need to be imported. If you look up new in the docs, for example, it is provided by racket/class or racket, not by racket/base, which explains the message you get.

frame% is provided by racket/gui or racket/gui/base, so finally this will work:

#lang racket
(require racket/gui)
(define FRAME (new frame% [label "Graphic"] [width 500] [height 500]))

The example you copy-pasted probably included the require statement.

Try to get comfortable with reading the Racket docs, they are well written and searchable.

Upvotes: 4

Related Questions