using external modules

Q&A's, tips, howto's
Locked
joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

using external modules

Post by joejoe »

hi -

im trying to use the web.lsp module:

http://static.artfulcode.net/newlisp/web.lsp.html

i added the file

http://static.artfulcode.net/newlisp/web.lsp.src.html

as web.lsp to the

/usr/share/newlisp/modules

directory on my debian squeeze i386 machine and went through the ./configure, make and make install again and tried to do a basic function call like this:

Code: Select all

> (Web:parse-url http://www.newlisp.org)

ERR: invalid function : (Web:parse-url http://www.newlisp.org)
> (parse-url http://www.newlisp.org)

ERR: invalid function : (parse-url http://www.newlisp.org)
> 
i know i am making a most basic error in trying this.

can anyone say what i am doing incorrectly? thanks very much!

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

This looks wrong:

Code: Select all

(Web:parse-url http://www.newlisp.org)


What is the type of the http part? If it's a string, it should be:

Code: Select all

(Web:parse-url "http://www.newlisp.org") 
It works OK for me after by simply loading the module into a newLISP session:

Code: Select all

> (load "/Users/me/code/dragonfly-framework/modules-active/web.lsp")
(lambda ((n 0)) 
 (when (zero? n) 
  (Web:close-session)) 
 (sys-exit))
> (Web:parse-url "http://www.newlisp.org")
(("scheme" "http") ("user" ()) ("pass" ()) ("host" "www.newlisp.org") ("port" nil) 
 ("path" "/") 
 ("query" nil) 
 ("fragment" nil))
> 
I don't do any of that configure/make stuff... :)

joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

Post by joejoe »

thanks cormullion!

i thought that by re-installing newlisp w/ the module in place, this would let me not have to load the web.lsp module manually. am i correct about this? i even put it in the nL unpacked modules directory before i re-ran the config/make/make install.

this is what i get when i try to run the http as a string, as you pointed out: (thanks again!)

Code: Select all

newLISP v.10.1.1 on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.

> (Web:parse-url "http://www.newlisp.org")

ERR: invalid function : (Web:parse-url "http://www.newlisp.org")
> 

m35
Posts: 171
Joined: Wed Feb 14, 2007 12:54 pm

Post by m35 »

joejoe wrote:i thought that by re-installing newlisp w/ the module in place, this would let me not have to load the web.lsp module manually. am i correct about this?
newLISP doesn't automatically detect and load modules, you always have to include a (load) statement to use a module's code.

For example, this should theoretically work (untested)

Code: Select all

> (load "/path-to-module/web.lsp")
> (Web:parse-url "http://www.newlisp.org")

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Post by xytroxon »

I think you are getting confused by how the load and module functions work...

From the newLISP manual:
Environment variable NEWLISPDIR

During startup, newLISP sets the environment variable NEWLISPDIR, if it is not set already. On Linux, BSDs, Mac OS X and other Unixes the variable is set to /usr/share/newlisp. On Win32 the variable is set to %PROGRAMFILES%/newlisp.

The environment variable NEWLISPDIR is useful when loading files installed with newLISP:

(load (append (env "NEWLISPDIR") "/guiserver.lsp"))

(load (append (env "NEWLISPDIR") "/modules/mysql.lsp"))

A predefined function module can be used to shorten the second statement loading from the modules/ directory:

(module "mysql.lsp")
-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

Post by joejoe »

xytroxon wrote:I think you are getting confused by how the load and module functions work...

From the newLISP manual:

[...]

-- xytroxon
understood. thank you xytroxon.

i appreciate you taking the time to point this out.

hilti
Posts: 140
Joined: Sun Apr 19, 2009 10:09 pm
Location: Hannover, Germany
Contact:

Post by hilti »

Hi Joejoe

check out my attempt of "auto-loading" modules. Download Dragonfly framework. It's in the file dragonfly.lsp

Just a few lines of code.

Cheers
Hilti
--()o Dragonfly web framework for newLISP
http://dragonfly.apptruck.de

joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

Post by joejoe »

hilti wrote:Hi Joejoe

check out my attempt of "auto-loading" modules. Download Dragonfly framework. It's in the file dragonfly.lsp

Just a few lines of code.

Cheers
Hilti
thanks for the help Hilti.

im refraining from using bsd/mit/non-copyleft code, so i am sticking to the core modules. i appreciate the insight, and if dragonfly every becomes gpl, you bet i will be all over it. :0) --joejoe

Locked