Reputation: 53806
I'm trying to set a dir to load files from using racket. I want to set the dir and then use command (load "extract.rktl")
to load the file.
I'm on windows environment.
Command I'm trying is :
(add-to-list 'load-path ("c:/Users/racket/")
I receive error :
add-to-list: undefined;
cannot reference undefined identifier
context...:
the dir c:\Users\racket exists. Are commands correct ?
Update : this helped : How do I include files in DrScheme?
Upvotes: 0
Views: 2114
Reputation: 3669
In Racket, path
is a type and strings are not paths. So convert the name of a path with string->path
.
(define default-dir
(string->path "c:\\user\\racket"))
Notes:
The Windows separator character '\' must be escaped as '\'.
Many Racket functions that act on paths will implicitly convert strings to paths without an explicit call to string->path
.
However string operations cannot be permed on path objects.
>(string-split default-dir "\\") string-split: contract violation expected: string? given: #<path:c:\user\racket>
Alternatively, a GUI can be used:
> (require racket/gui)
> (define my-file (get-file))
> my-file
#<path:/home/ben/Documents/racket/my-module.rkt>
Upvotes: 1