Source language: Translate to:

hpwNewLISP - interface plugin to newLISP

Questions about NeoBook PlugIns

Moderator: Neosoft Support

Postby cp4w » Wed Dec 27, 2006 3:57 pm

Hi

I'm finally learning a little newlisp and want to start actively using this great plug-in.

Here is my question.
The following works fine
Code: Select all
SetVar "[MyList]" "A B C d"

hpwNewLispCall "( slice '([MyList]) 1 2)" "[LispReturn]"


But if I want the list to contain entries with spaces like (A B "A C" D)
how do I do this.


Code: Select all
SetVar "[MyList]" "A B [#34]A C[#34] D"

hpwNewLispCall "( slice '([MyList]) 1 2)" "[LispReturn]"

Does not work
cp4w
 
Posts: 533
Joined: Sun Apr 03, 2005 4:37 pm
Location: Great Neck, NY

Postby dpayer » Wed Dec 27, 2006 4:06 pm

shx wrote:Hi

I'm finally learning a little newlisp and want to start actively using this great plug-in.

Here is my question.
The following works fine
Code: Select all
SetVar "[MyList]" "A B C d"

hpwNewLispCall "( slice '([MyList]) 1 2)" "[LispReturn]"


But if I want the list to contain entries with spaces like (A B "A C" D)
how do I do this.


Code: Select all
SetVar "[MyList]" "A B [#34]A C[#34] D"

hpwNewLispCall "( slice '([MyList]) 1 2)" "[LispReturn]"

Does not work


Did you try the ascii code for the space which is #32

See http://www.asciitable.com/ for a full list of ascii values.

David P.
User avatar
dpayer
 
Posts: 1382
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Sam Cox » Wed Dec 27, 2006 4:22 pm

Hello shx,

When using newLisp, you will have to become familiar with a new data structure that has no counterpart in Neobook. That data structure is called a list.

In your example, the Neobook variable [MyList] is really a string of 7 characters "A" "[#32]" "B" "[#32]" "C" "[#32]" and "d", but when used as indicated in your newLisp statement, it becomes a list of just four symbols. In effect, your call to newLisp is:
Code: Select all
hpwNewLispCall "(slice '(A B C d) 1 2)" "[LispReturn]"

The white "stuff" between the symbols A, B, C and d are not spaces—at least from newLisp's point of view. The slice function sees a list of four symbols and returns (B C) as expected—slice returns a two symbol list. When the result is passed back to the variable [LispReturn], Neobook receives the string "(B C)" because Neobook doesn't know anything about lists.

You can ask newLisp's slice function to work on strings instead of lists. To do so, you must pass it a string instead of a list. To pass a string to newLisp, you must quote it. Here's one way—the hard way:
Code: Select all
hpwNewLispCall "(slice [#32][MyList][#32] 1 2)" "[LispReturn]"

which returns the two-character string " B" (notice leading space) to Neobook.

Notice that you CANNOT write the following and expect it to work:
Code: Select all
hpwNewLispCall "(slice [MyList] 1 2)" "[LispReturn]"

because newLisp will see:
Code: Select all
(slice A B C d 1 2)

which will generate an error. The slice function wants to see:
Code: Select all
(slice "A B C d" 1 2)

Happily, newLisp has other ways of quoting string. For strings shorter than 2048 characters, you can use left and right curly braces instead of double-quote characters. The newLisp call becomes:
Code: Select all
hpwNewLispCall "(slice {[MyList]} 1 2)" "[LispReturn]"

which is exactly equivalent to the previous example.

I hope this explanation helps. Welcome to the fantastic world of newLisp plus Neobook. The combination is incredibly powerful, but the interface between the two programs takes a bit of getting used to.

-- Sam
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby HPW » Wed Dec 27, 2006 11:34 pm

Shx,

For using newLISP in neobook you have to understand 2 things:

1: How does native newLISP-calls works (Using the standalone newLISP-tk enviroment to try things out can help)

2: How does neobook handle parameters before they are send to a plugin-command? For example: 'Is a double quote evaluated by neobook at first or not'

After getting familar with this conzept, you get a powerhorse at your finger-tips!

Sam: Thanks for the explanations

:wink:
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby cp4w » Thu Dec 28, 2006 7:58 am

Thanks dpayer, Sam, hpw for your help and that hpw for the great plug-in.

Just to point out that I am using Cormullions very excellent Introduction to Newlisp to help me get started.


If you could help to clarify a little further how newlisp works with lists.

This works
Code: Select all
SetVar "[mycmd]" "[#34]a b[#34] [#34]a n[#34] [#34]a p[#34]"

hpwNewLispCall "(slice '([mycmd]) 0 2)" "[lispreturn]"

I get back
("a b" "a n")


Now If I want to show it in Neobook listbox I convert it. I do
Code: Select all
StrReplace "[LispReturn]" "[#34] [#34]" "[#13]" "[testnewlisp]"
StrReplace "[testnewlisp]" "([#34]" "" "[testnewlisp]"
StrReplace "[testnewlisp]" "[#34])" "" "[testnewlisp]"

Is there an easier way?
cp4w
 
Posts: 533
Joined: Sun Apr 03, 2005 4:37 pm
Location: Great Neck, NY

Postby Wrangler » Thu Dec 28, 2006 9:14 am

Hmmm. Got me interested. Tried to go to http://newlisp.org and I get couldn't connect to remote server. Also tried with the www. Is it me, or is anyone else having this problem?
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1506
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby Sam Cox » Thu Dec 28, 2006 10:18 am

Hi Wrangler,

Must be you. Clicking your http://newlisp.org/ link worked for me.

-- Sam
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Wrangler » Thu Dec 28, 2006 10:24 am

Clicking YOUR link doesn't work for me neither. Tried in Opera and IE. Must be a router down in my area. Will try again later. Thanks for checking, Sam.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1506
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby Sam Cox » Thu Dec 28, 2006 10:57 am

Hi Steven,

Starting with your code:
Code: Select all
setvar "[mycmd]" "[#34]a b[#34] [#34]a n[#34] [#34]a p[#34]"
hpwnewLispCall "(slice '([mycmd]) 0 2)" "[result]"

Follow it with this:
Code: Select all
hpwnewLispCall "(join '[result] {[#13]})" "[result]"

to join the elements of the list in [result] into a single string. The {[#13]} argument puts a [#13] character between each of the strings in [result].

You can do all of this in one command:
Code: Select all
hpwNewLispCall "(join (slice '([mycmd]) 0 2) {[#13]})" "[result]"

in which I simply wrapped the (join ...) command around the slice command. Wrapping functions around the results of other functions is a very common idiom in newLisp.
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Sam Cox » Thu Dec 28, 2006 10:59 am

Hi Wrangler,

Here's a link to the newLisp forum: http://www.alh.net/newlisp/phpbb/

-- Sam

TO EVERYONE:
LET'S CONTINUE THIS DISCUSSION IN ANOTHER
THREAD SO THAT WE DON'T BECOME GUILTY OF
HIJACKING HPW'S ON-GOING NEWLISP RELEASE
THREAD.
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Wrangler » Thu Dec 28, 2006 11:05 am

Thanks, Sam. That link works for me. Still can't get the other to work. Even upgraded Opera. Firefox won't let me go there neither.

I've been wanting to dive into newlisp since Hans first came out with the plug. Haven't had the time to devote to it yet. Have 3 other shareware titles that need finishing. I'll take a close look over the weekend. I'll cruise the forum to get an idea of what power it has.

Hope you're warm and snuggy up there in CO. I heretell you guys got a lot of the white stuff this year.

Happy New Year to you and your family.

Later: Just saw your suggestion. I agree.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1506
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby HPW » Mon Feb 05, 2007 12:02 pm

Just upload hpwNewLISP 2.20:

http://www.hpwsoft.de/anmeldung/html1/n ... ook14.html

Bugfix for nbfreelib introduced with 2.19 with the new privat variables to import DLL-functions.

When you used the nbdllreg together with nbfreelib, take a look into your [Temp] where some undeleted *.nbr could exist.
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby HPW » Thu Feb 15, 2007 5:22 am

For the interested newLISP users: newLISP 9.1 (next stable major-release)

http://newlisp.org/downloads/

Release notes: http://newlisp.org/downloads/newLISP-9.1-Release.html
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby HPW » Wed Mar 14, 2007 2:50 pm

I am not sure what had happened, but the newlisp command sensitive help in the command wizard editor is no longer working on my XP.

I highlight the command 'setq' and hit F1.

In the past the browser opens with:

C:\Programme\newlisp\newlisp_manual.html#setq

Now it is only:

C:\Programme\newlisp\newlisp_manual.html

and it does no more jump to the command-doc.

I do not know if it is related with the IE7 update.
Does MS no more allow jump-targets with .html#...

Same happens in the newLISP IDE.

Strange?
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby dpayer » Thu Mar 15, 2007 7:07 am

HPW wrote:I am not sure what had happened, but the newlisp command sensitive help in the command wizard editor is no longer working on my XP.

I do not know if it is related with the IE7 update.
Does MS no more allow jump-targets with .html#...

Same happens in the newLISP IDE.

Strange?


Hans-Peter,
I did a google search and found that others were having problems too, particularly when using IE in a programing environment:

http://www.google.com/search?hl=en&q=ie7+anchors

Not all pertain to you but I think there is an issue.

David P.
User avatar
dpayer
 
Posts: 1382
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

PreviousNext

Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 2 guests

cron