Page 10 of 14

PostPosted: Wed Dec 27, 2006 3:57 pm
by cp4w
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

PostPosted: Wed Dec 27, 2006 4:06 pm
by dpayer
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.

PostPosted: Wed Dec 27, 2006 4:22 pm
by Sam Cox
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

PostPosted: Wed Dec 27, 2006 11:34 pm
by HPW
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:

PostPosted: Thu Dec 28, 2006 7:58 am
by cp4w
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?

PostPosted: Thu Dec 28, 2006 9:14 am
by Wrangler
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?

PostPosted: Thu Dec 28, 2006 10:18 am
by Sam Cox
Hi Wrangler,

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

-- Sam

PostPosted: Thu Dec 28, 2006 10:24 am
by Wrangler
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.

PostPosted: Thu Dec 28, 2006 10:57 am
by Sam Cox
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.

PostPosted: Thu Dec 28, 2006 10:59 am
by Sam Cox
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.

PostPosted: Thu Dec 28, 2006 11:05 am
by Wrangler
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.

PostPosted: Mon Feb 05, 2007 12:02 pm
by HPW
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.

PostPosted: Thu Feb 15, 2007 5:22 am
by HPW
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

PostPosted: Wed Mar 14, 2007 2:50 pm
by HPW
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?

PostPosted: Thu Mar 15, 2007 7:07 am
by dpayer
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.