newlisp calling a library function crashes

Q&A's, tips, howto's
Locked
starseed
Posts: 38
Joined: Thu Jul 27, 2006 8:45 pm

newlisp calling a library function crashes

Post by starseed »

Hi,

I'm having a problem with a library call.
I'm still trying to get newLisp to use IUP(1), and now I have to call a function with a variable number of arguments, which expects NULL as the last.

And whenever I call the function, newLisp crashes.

Code: Select all

(context 'iup)

(set 'iup-imports '(
   (iup.dll IupOpen IupDestroy IupClose IupSetHandle) 
   (iup.dll IupSetLanguage IupGetLanguage)
   (iup.dll IupImage IupLabel IupDialog IupShowXY IupShow IupVbox IupHbox  )
   ;;;; CONTROLS
   (iup.dll IupButton IupMultiLine)
   ;;;; EVENT Handling
   (iup.dll IupMainLoop IupLoopStep IupFlush IupGetCallback IupSetCallback 
            IupGetActionName IupGetFunction IupSetFunction 
            )
   ;;;; ATTRIBUTE handling
   (iup.dll 
      IupStoreAttribute
      IupSetAttribute IupSetAttributes IupSetfAttribute ;IupSetAttributeHandle 
      IupGetAttribute IupGetAttributes ;IupGetAttributeHandle 
      IupGetFloat IupGetInt
      IupStoreGlobal IupSetGlobal IupGetGlobal
      IupGetType IupHelp
      )
   (iup.dll
      IupVbox IupVbox IupZbox IupFrame IupAppend)
   ;;;;  pre-defined DIALOGS
   (iup.dll IupGetFile IupMessage IupAlarm IupScanf IupListDialog IupGetText
            )
   ;IupMessagef ???

   )
)

(define (setup )
  (dolist (dll-info iup-imports)
     (set 'dll-name (first dll-info))
     (dolist (func-name (rest dll-info))
         (import (string dll-name) (string func-name))))

   (set 'loaded true)
  )

(define (test-box)
   (IupOpen)
   (IupSetLanguage "ENGLISH")

   (set 'btn (IupButton "Test" nil))
   
   (print 'define-hbox)
   (set 'hb (IupHbox nil))
   ; --- the following line is never reached
   ; same with (set 'hb (IupHbox btn nil))
   (print 'define-dlg)
   (set 'dlg (IupDialog hb))
   
   (print 'show-dlg)
   (IupShow dlg)
   (IupMainLoop)
   (IupDestroy dlg)
   (IupClose)
)   

(setup)
(test-box)
(context 'MAIN)

Any idea what's happening here?


Thanks,

Ingo



(1) http://luaforge.net/projects/iup/

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

'nil' is not the same thing as NULL or the number 0 in the C language:

instead of:

Code: Select all

(set 'btn (IupButton "Test" nil)) 
(set 'hb (IupHbox nil))
try:

Code: Select all

(set 'btn (IupButton "Test" 0)) 
(set 'hb (IupHbox 0))
Lutz

starseed
Posts: 38
Joined: Thu Jul 27, 2006 8:45 pm

Post by starseed »

Thanks Lutz,

I started to assume something like this, and seems you were right. My first test worked!


Kind regards,

Ingo

Locked