imported function parameter question

Started by HPW, December 13, 2003, 11:10:08 AM

Previous topic - Next topic

HPW

#15
Sam,



Shouldn't it be:

(define (repchr n char-index)
     (join (map char (series char-index 1 n))))

(repchr 10 32) -> "          " ; 10 spaces
(repchr 10 65) -> "AAAAAAAAAA"

because:

> (repstr "AB" 10)
"ABABABABABABABABABAB"

All 3 functions have their use.

I think Lutz allocate fits best for init the varspace for OS-calls,

because the function name stand for its use.
Hans-Peter

HPW

#16
>This is what you get in 7.4.0:

>(1) floats can be passed (see 7.4.0 release manual for example)

>(2) up to 14 parameters can be passed (floats count double)



Have not found an example for float-support in the manual of RC3.

Can you provide one here?
Hans-Peter

Lutz

#17
actually there is one:



(printf "%g %s %d %cn" 1.23 "hello" 999 65)  ; the 1.23 is a float



it is so transparent to the user now, that it is easily overlooked :-)



I am glad the DLL has such a good work-out with you, I hopt that the 14 pareameter slots are enought. I remember in one of your posts you needed 5*2 + 3 = 13 already. I could have gone to 16. But just going from 10 to 14 added about 500 bytes to the executable.



Also, for initializing memory Sam's version seems to be the best (fastest) to me:



 (define (repstr n char-index)

     (join (map char (series char-index 1 n))))



I guess the original point of this 'initialize memory contest' for me is that a solution with 'dotimes' is most of the time not necessary in LISP, 'map' is much faster and elegant.



Lutz

HPW

#18
After a quick look in the API-reference of one possible target-DLL I check for max parameter:



function AddNoteAnnotation(Left As Double,
Top As Double,
AnnotType As Long,
PopupLeft As Double,
PopupTop As Double,
PopupWidth As Double,
PopupHeight As Double,
Title As String,
Contents As String,
Red As Double,
Green As Double,
Blue As Double,
Open As Long) As Long


9 x double and 4 other.

But the question is, if it is usefull to make newLISP so capabel, or use another wrapper DLL to translate from lesser parameter to this rarly used functions. Most functions can be used with 14 or 16 parameter.
Hans-Peter

Lutz

#19
what I need is some 'C' function which looks like



vacall(*functionPtr, *args[])



then I could write something general for as many parameters as you want. But how things are at the moment, I have to code (see nl-import.c ):



result = (*function)(args[0], args[1] ...... );



for every n from 0 to 14 (or 9*2 + 4 = 22 in your post), and it wastes a lot of space for a functionality rarely used.



there are the va_list(), va_start(), va_arg() macros but that doesn't help me if I don't have a function to bring the args on the call stack.



does anybody have an idea?



Lutz

HPW

#20
>But just going from 10 to 14 added about 500 bytes to the executable.



So does we speak about 1 KB for 14 to 22 ?



>for every n from 0 to 14 (or 9*2 + 4 = 22 in your post),

>and it wastes a lot of space for a functionality rarely used.



Lot of space is relativ, because newLISP is so incredibel small.

Of cource you are right. When it is so rarly used by the majority

of users, it must give other workarounds through wrapper-dlls.



>then I could write something general for as many parameters as you want.



General solution are always the best. :-) But they must be possible. :-(



>does anybody have an idea?



My C knowledge is only basic and far away from a professional level.

In my used programming enviroments I mostly do not think about stacks.

(Only when I get a stack overflow)

Thats why I love lisp in all flavours! The enviroments care for me.
Hans-Peter

HPW

#21
Things get going. After the promising last enhancements, I ordered yesterday a licence for a PDF-DLL.



newLISP v7.4.0 Copyright (c) 2003 Lutz Mueller. All rights reserved.

> (import "iSEDQuickPDF.DLL" "iSEDNewDocument")
iSEDNewDocument <117D49C>
> (import "iSEDQuickPDF.DLL" "iSEDUnlockKey")
iSEDUnlockKey <117D3DC>
> (import "iSEDQuickPDF.DLL" "iSEDDrawText")
iSEDDrawText <117DE70>
> (import "iSEDQuickPDF.DLL" "iSEDSaveToFile")
iSEDSaveToFile <117D568>

> (iSEDUnlockKey "your license key here")
1
> (iSEDNewDocument)
18493748
> (iSEDDrawText 100.0 500.0 "Hello World")
1
> (iSEDSaveToFile "C:/temp/iSEDtest1.pdf")
1
>

Bingo, PDF generated with newlisp.



Seems very powerfull and affordable (65$).



http://www.sedtech.com/isedquickpdf/?page=home">http://www.sedtech.com/isedquickpdf/?page=home



PS: This was the package with the max.22 slots!
Hans-Peter