Page 1 of 1
					
				using external modules
				Posted: Tue Sep 08, 2009 6:40 pm
				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!
 
			 
			
					
				
				Posted: Tue Sep 08, 2009 7:35 pm
				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... :)
 
			 
			
					
				
				Posted: Wed Sep 09, 2009 1:12 pm
				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")
> 
 
			 
			
					
				
				Posted: Wed Sep 09, 2009 4:03 pm
				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")
 
			 
			
					
				
				Posted: Wed Sep 09, 2009 7:21 pm
				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
 
			 
			
					
				
				Posted: Thu Sep 10, 2009 12:04 pm
				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.
 
			 
			
					
				
				Posted: Fri Sep 18, 2009 9:47 am
				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
			 
			
					
				
				Posted: Fri Sep 18, 2009 2:52 pm
				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