• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

DLL / Inputbox example + LionBasic :)

Started by Frank Brübach, September 28, 2009, 07:56:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

hi all dear powerbasic users,

I am quite new here using powerbasic and want to learn more about this language. I know yet thinbasic / freebasic languages a little and have a lot of good ideas to create new things (main part: graphics).

I would like to understand how to work with creating own dll's and try to build perhaps own little applications with powerbasic and add some days new functions to this one. but I don't know how I should going on. So I tried to test code from powerbasic archive (dll creating with "modal dialogue").
I found modal dialogue / input test. but the code is very old and perhaps somebody has updated this code into the current pb 9.1 version I am working with or can do this for me, would be very nice ;)

old code:


'
' Example DLL to display a modal dialog and return a value to the calling
' application.
'
' Requires PB/DLL v1.10 or later to compile.
'

$COMPILE DLL

$INCLUDE "WIN32API.INC"

DECLARE FUNCTION InputDlgProc(BYVAL hDlg AS INTEGER, _
                              BYVAL wMsg AS INTEGER, _
                              BYVAL wParam AS INTEGER, _
                              BYVAL lParam AS LONG) AS INTEGER


GLOBAL DlgAddr      AS DWORD
GLOBAL hCurInstance AS WORD

GLOBAL gText        AS ASCIIZ * 255
GLOBAL gCaption     AS ASCIIZ * 255
GLOBAL gDefault     AS ASCIIZ * 255

FUNCTION LIBMAIN (BYVAL hInstance AS LONG, _
                  BYVAL wDataSeg AS DWORD, _
                  BYVAL wHeapSize AS DWORD, _
                  lpszCmdLine AS ASCIIZ) EXPORT AS INTEGER ' ??? mistake here?

  'Save the instance handle of the DLL
  hCurInstance = hInstance

  'Remember! We have to return a "one" to indicate successful
  '          initialization
  LIBMAIN      = 1   'success!

END FUNCTION


FUNCTION InputBox(TEXT AS ASCIIZ PTR, _
                  Caption AS ASCIIZ PTR, _
                  DEFAULT AS ASCIIZ PTR) EXPORT AS INTEGER

  ' Get the address of the dialog callback
  DlgAddr = MakeProcInstance(CODEPTR(InputDlgProc), hCurInstance)

  ' If pointers are non-null, set default values for dialog
  IF TEXT THEN
    gText = @TEXT
  ELSE
    gText = "Enter Text"
  END IF

  IF Caption THEN
    gCaption = @Caption
  ELSE
    gCaption = "INPUT BOX"
  END IF

  IF DEFAULT THEN
    gDefault = @DEFAULT
  ELSE
    gDefault = ""
  END IF

  ' Pop up the modal dialog and get return value
  FUNCTION = DialogBox(hCurInstance, "INPUTBOX", 0, DlgAddr)

  ' If default buffer was passed, return the input text
  IF DEFAULT THEN
    @DEFAULT = gDefault
  END IF

END FUNCTION


' **
' ** Generic routine to center any window given its handle.
' **
SUB CenterWindow(BYVAL hWnd AS WORD)

  DIM WndRect AS RECT
  DIM x       AS INTEGER
  DIM y       AS INTEGER

  GetWindowRect hWnd, WndRect

  x = (GetSystemMetrics(%SM_CXSCREEN)-(WndRect.nRight-WndRect.nLeft))\2
  y = (GetSystemMetrics(%SM_CYSCREEN)-(WndRect.nBottom-WndRect.nTop+GetSystemMetrics(%SM_CYCAPTION)))\2

  SetWindowPos hWnd, %NULL, x, y, 0, 0, %SWP_NOSIZE OR %SWP_NOZORDER

END SUB


FUNCTION InputDlgProc(BYVAL hDlg AS INTEGER, _
                      BYVAL wMsg AS INTEGER, _
                      BYVAL wParam AS INTEGER, _
                      BYVAL lParam AS LONG) EXPORT AS INTEGER

  ' See INPUTBOX.RC script for details on the dialog itself

  SELECT CASE wMsg
    CASE %WM_INITDIALOG

      'Center the window
      CenterWindow hDlg

      'Assign the initial values to the dialog
      SetWindowText GetDlgItem(hDlg, 101), gText
      SetWindowText GetDlgItem(hDlg, 102), gDefault
      SetWindowText hDlg, gCaption

      FUNCTION = 1
      EXIT FUNCTION

    CASE %WM_COMMAND
      SELECT CASE wParam
        CASE 103, %IDOK
          'When the "OK" button is pressed, get the edit box value
          ' and end the dialog
          GetWindowText GetDlgItem(hDlg, 102), gDefault, 255
          EndDialog hDlg, 1
          FUNCTION = 1
          EXIT FUNCTION
          'When the "CANCEL" button is pressed, or escape is pressed, or
          ' the dialog is closed, end the dialog
        CASE 104, %IDCANCEL
          EndDialog hDlg, 0
          FUNCTION = 1
          EXIT FUNCTION
      END SELECT
  END SELECT

END FUNCTION



Testexample:


'
' Example of calling a DLL which has a modal dialog resource
'
' Modal Dialog is a generic input box
'

$COMPILE EXE

DECLARE FUNCTION MessageBox LIB "USER" (BYVAL hWnd AS WORD, lpText AS ASCIIZ, lpCaption AS ASCIIZ, BYVAL wTYPE AS WORD) AS INTEGER
DECLARE FUNCTION InputBox LIB "INPUTBOX" (Question AS ASCIIZ,
                                          Caption AS ASCIIZ,
                                          DEFAULT AS ASCIIZ) AS INTEGER

FUNCTION WINMAIN (BYVAL hCurInstance AS INTEGER, _
                  BYVAL hPrevInstance AS INTEGER, _
                  lpCmdLine AS ASCIIZ, _
                  BYVAL nCmdShow AS INTEGER) AS INTEGER

  DIM Answer AS ASCIIZ * 255

  'Set default answer value
  Answer = "Dave Navarro"

  'Call the DLL with the modal dialog
  IF InputBox("Enter Complete User Name", "User Name Dialog", Answer) THEN
    'Display the result
    MessageBox 0, "You entered: " + Answer, "Input Box DLL Test", 0
  ELSE
    MessageBox 0, "Cancel was pressed!", "Input Box DLL Test", 0
  END IF

END FUNCTION


hope somebody can help, so it's my first step to get closer to powerbasic. thanks in advance. wish all a good evening from centre of germany.

don't know where to place the code and my question so I do it here. Hope to have also some fun here at this board while learning new things :)

best regards, frank

Frederick J. Harris

Hi Frank!

   Welcome!  I didn't try to run the code but doesn't it compile for you?  If you copied code from an earlier version of PowerBASIC, there has been a recent change that pointer parameters have to be passed Byval.

Fred

Frederick J. Harris

#2
Frank,

    I fixed multiple errors in the dll.  This at least compiles to a dll.  You'll have to investigate for changes.


'
' Example DLL to display a modal dialog and return a value to the calling
' application.
'
' Requires PB/DLL v1.10 or later to compile.
'

$COMPILE DLL

$INCLUDE "WIN32API.INC"

DECLARE FUNCTION InputDlgProc(BYVAL hDlg AS INTEGER, _
                             BYVAL wMsg AS INTEGER, _
                             BYVAL wParam AS INTEGER, _
                             BYVAL lParam AS LONG) AS INTEGER


GLOBAL DlgAddr      AS DWORD
GLOBAL hCurInstance AS WORD

GLOBAL gText        AS ASCIIZ * 255
GLOBAL gCaption     AS ASCIIZ * 255
GLOBAL gDefault     AS ASCIIZ * 255

Function LibMain(ByVal hInstance As Long,ByVal fwdReason As Long,ByVal lpvReserved As Long) Export As Long

'FUNCTION DLLMAIN (BYVAL hInstance AS LONG, BYVAL wDataSeg AS DWORD, BYVAL wHeapSize AS DWORD, Byval lpszCmdLine AS ASCIIZ) EXPORT AS INTEGER ' ??? mistake here?

 'Save the instance handle of the DLL
 hCurInstance = hInstance

 'Remember! We have to return a "one" to indicate successful
 '          initialization
 LIBMAIN      = 1   'success!

END FUNCTION


FUNCTION InputBox(Byval TEXT AS ASCIIZ PTR, Byval Caption AS ASCIIZ PTR, Byval pDEFAULT AS ASCIIZ PTR) EXPORT AS INTEGER

 ' Get the address of the dialog callback
 DlgAddr = CODEPTR(InputDlgProc)

 ' If pointers are non-null, set default values for dialog
 IF TEXT THEN
   gText = @TEXT
 ELSE
   gText = "Enter Text"
 END IF

 IF Caption THEN
   gCaption = @Caption
 ELSE
   gCaption = "INPUT BOX"
 END IF

 IF pDEFAULT THEN
   gDefault = @pDEFAULT
 ELSE
   gDefault = ""
 END IF

 ' Pop up the modal dialog and get return value
 FUNCTION = DialogBox(hCurInstance, "INPUTBOX", 0, DlgAddr)

 ' If default buffer was passed, return the input text
 IF pDEFAULT THEN
   @pDEFAULT = gDefault
 END IF

END FUNCTION


' **
' ** Generic routine to center any window given its handle.
' **
SUB CenterWindow(BYVAL hWnd AS WORD)

 DIM WndRect AS RECT
 DIM x       AS INTEGER
 DIM y       AS INTEGER

 GetWindowRect hWnd, WndRect

 x = (GetSystemMetrics(%SM_CXSCREEN)-(WndRect.nRight-WndRect.nLeft))\2
 y = (GetSystemMetrics(%SM_CYSCREEN)-(WndRect.nBottom-WndRect.nTop+GetSystemMetrics(%SM_CYCAPTION)))\2

 SetWindowPos hWnd, %NULL, x, y, 0, 0, %SWP_NOSIZE OR %SWP_NOZORDER

END SUB


FUNCTION InputDlgProc(BYVAL hDlg AS INTEGER, _
                     BYVAL wMsg AS INTEGER, _
                     BYVAL wParam AS INTEGER, _
                     BYVAL lParam AS LONG) EXPORT AS INTEGER

 ' See INPUTBOX.RC script for details on the dialog itself

 SELECT CASE wMsg
   CASE %WM_INITDIALOG

     'Center the window
     CenterWindow hDlg

     'Assign the initial values to the dialog
     SetWindowText GetDlgItem(hDlg, 101), gText
     SetWindowText GetDlgItem(hDlg, 102), gDefault
     SetWindowText hDlg, gCaption

     FUNCTION = 1
     EXIT FUNCTION

   CASE %WM_COMMAND
     SELECT CASE wParam
       CASE 103, %IDOK
         'When the "OK" button is pressed, get the edit box value
         ' and end the dialog
         GetWindowText GetDlgItem(hDlg, 102), gDefault, 255
         EndDialog hDlg, 1
         FUNCTION = 1
         EXIT FUNCTION
         'When the "CANCEL" button is pressed, or escape is pressed, or
         ' the dialog is closed, end the dialog
       CASE 104, %IDCANCEL
         EndDialog hDlg, 0
         FUNCTION = 1
         EXIT FUNCTION
     END SELECT
 END SELECT

END FUNCTION


Added later:

     I changed the Dll entry point function;
     I added byval to pointer parameters in several instances;
     I eliminated the MakeProcInstance() call.  According to 1999 documentation, that was was obsolete (so it was obsolete in 1999 already).

José Roca

 
That code is prehistoric. It is for a 16-bit compiler. Besides, it is incomplete: it lacks a resource file for the dialog box template. Also, the declares are incorrect.

Frederick J. Harris

#4
Yes, the DialogBox() Api call requires in its 2nd parameter a pointer to a Dialog Box template in a rc file. You've really, really, dug up some ancient code Frank.  If you are just trying to learn PowerBASIC I'd recommend you find more recent code.

PS - added later.  I've almost got the code to run.  If you can come up with that rc file I'll see what I can do.

Frank Brübach

#5
hi frederick, josé,

yes, very old code, but that's not my mistake ;) would be better to update the old file from powerbasic.com website ( http://www.powerbasic.com/support/downloads/demos.htm ). I have searched for an example with dll and have got at first this InputDll example for modal dialogue. So I am starting with a lot of trouble causing, but it's funny.

rc file I have found I try to add below.

my results coming up to this end and the Inputbox$ line doesn't like me any more.

'
' Example of calling a DLL which has a modal dialog resource
'
' Frankos '-- Modal Dialog is a generic input box
'

$COMPILE EXE
#DIM ALL

DECLARE FUNCTION MessageBox LIB "USER" (BYVAL hWnd AS WORD, lpText AS ASCIIZ, lpCaption AS ASCIIZ, BYVAL wTYPE AS WORD) AS INTEGER

DECLARE FUNCTION InputBox LIB "Inputbox"(BYVAL TEXT AS ASCIIZ PTR, BYVAL Caption AS ASCIIZ PTR, BYVAL pDEFAULT AS ASCIIZ PTR, BYVAL answer AS ASCIIZ PTR) AS INTEGER

FUNCTION WINMAIN(BYVAL hInstance AS DWORD,BYVAL fwdReason AS LONG,BYVAL lpvReserved AS LONG, BYVAL hCurInstance AS DWORD) AS LONG

 DIM answer AS ASCIIZ PTR* 255

 'Set default answer value
 MSGBOX "franko d'artagnon", answer

 'Call the DLL with the modal dialog
'if answer =  InputBOX$ ("Enter Complete User Name",, "User Name Dialog") then

   'Display the result
   MSGBOX "You entered: ", answer, "Input Box DLL Test"
'ELSE
   MSGBOX "Cancel was pressed!",, "Input Box DLL Test"
'END IF

 FUNCTION = 1

END FUNCTION



thanks a lot for trying / helping to fix this strange code from "lord of the rings" times :)
I have tried it over one hour. frederick you are right: better to use new code examples, right now!

if anybody has a running and current code about this theme or a link with dll handling would be also great.

best regards, Frank


Frederick J. Harris

Hi Frank!

    That example is almost unimaginable on several different levels.  First off, its using the Windows Api to create a Dialog Box!  For almost as long as I can remember PowerBASIC has had something called DDT that is its own Api for creating dialog boxes.

     Second, PowerBASIC has its own InputBox function as part of the compiler!  Its not necessary to create one - let alone in a DLL!

     Give me a bit and I'll get it working though if the rc file is OK.  I had to change piles of lines of code.

Fred

José Roca

 
I have translated the code. Download the attached file.

As it was 16-bit code, it was using integers instead of longs and WORD instead of DWORD for the instance handle... and several other things...

Things have changed a bit since PB/DLL 1 :)


'
' Example DLL to display a modal dialog and return a value to the calling
' application.

#COMPILE DLL

#INCLUDE "WIN32API.INC"
#RESOURCE "MyInputBox.pbr"

GLOBAL hCurInstance AS DWORD

GLOBAL gText        AS ASCIIZ * 255
GLOBAL gCaption     AS ASCIIZ * 255
GLOBAL gDefault     AS ASCIIZ * 255

'-------------------------------------------------------------------------------
' Main DLL entry point called by Windows...
'
FUNCTION LIBMAIN (BYVAL hInstance   AS LONG, _
                  BYVAL fwdReason   AS LONG, _
                  BYVAL lpvReserved AS LONG) AS LONG

   SELECT CASE fwdReason

   CASE %DLL_PROCESS_ATTACH
      'Indicates that the DLL is being loaded by another process (a DLL
      'or EXE is loading the DLL).  DLLs can use this opportunity to
      'initialize any instance or global data, such as arrays.

      hCurInstance = hInstance

      FUNCTION = 1   'success!

      'FUNCTION = 0   'failure!  This will prevent the EXE from running.

   CASE %DLL_PROCESS_DETACH
      'Indicates that the DLL is being unloaded or detached from the
      'calling application.  DLLs can take this opportunity to clean
      'up all resources for all threads attached and known to the DLL.

      FUNCTION = 1   'success!

      'FUNCTION = 0   'failure!

   CASE %DLL_THREAD_ATTACH
      'Indicates that the DLL is being loaded by a new thread in the
      'calling application.  DLLs can use this opportunity to
      'initialize any thread local storage (TLS).

      FUNCTION = 1   'success!

      'FUNCTION = 0   'failure!

   CASE %DLL_THREAD_DETACH
      'Indicates that the thread is exiting cleanly.  If the DLL has
      'allocated any thread local storage, it should be released.

      FUNCTION = 1   'success!

      'FUNCTION = 0   'failure!

   END SELECT

END FUNCTION


FUNCTION MyInputBox ALIAS "MyInputBox" ( _
                    BYVAL strText AS STRING, _
                    BYVAL strCaption AS STRING, _
                    BYREF szDefault AS ASCIIZ) EXPORT AS LONG

   ' If pointers are non-null, set default values for dialog
   IF strText <> "" THEN
      gText = strText
   ELSE
      gText = "Enter Text"
   END IF

   IF strCaption <> "" THEN
      gCaption = strCaption
   ELSE
      gCaption = "INPUT BOX"
    END IF

   IF VARPTR(szDefault) THEN
      gDefault = szDefault
   ELSE
      gDefault = ""
   END IF

   ' Pop up the modal dialog and get return value
   FUNCTION = DialogBoxParam(hCurInstance, "INPUTBOX", 0, CODEPTR(InputDlgProc), 0)

   ' If default buffer was passed, return the input text
   IF VARPTR(szDefault) THEN
      szDefault = gDefault
   END IF

END FUNCTION


' **
' ** Generic routine to center any window given its handle.
' **
SUB CenterWindow(BYVAL hWnd AS WORD)

   DIM WndRect AS RECT
   DIM x       AS INTEGER
   DIM y       AS INTEGER

   GetWindowRect hWnd, WndRect

   x = (GetSystemMetrics(%SM_CXSCREEN)-(WndRect.nRight-WndRect.nLeft))\2
   y = (GetSystemMetrics(%SM_CYSCREEN)-(WndRect.nBottom-WndRect.nTop+GetSystemMetrics(%SM_CYCAPTION)))\2

   SetWindowPos hWnd, %NULL, x, y, 0, 0, %SWP_NOSIZE OR %SWP_NOZORDER

END SUB


FUNCTION InputDlgProc(BYVAL hDlg AS INTEGER, _
                      BYVAL wMsg AS INTEGER, _
                      BYVAL wParam AS INTEGER, _
                      BYVAL lParam AS LONG) EXPORT AS LONG

   ' See INPUTBOX.RC script for details on the dialog itself

   SELECT CASE wMsg
      CASE %WM_INITDIALOG

         'Center the window
         CenterWindow hDlg

         'Assign the initial values to the dialog
         SetWindowText GetDlgItem(hDlg, 101), gText
         SetWindowText GetDlgItem(hDlg, 102), gDefault
         SetWindowText hDlg, gCaption

         FUNCTION = 1
         EXIT FUNCTION

      CASE %WM_COMMAND
         SELECT CASE wParam
            CASE 103, %IDOK
               'When the "OK" button is pressed, get the edit box value
               ' and end the dialog
               GetWindowText GetDlgItem(hDlg, 102), gDefault, 255
               EndDialog hDlg, 1
               FUNCTION = 1
               EXIT FUNCTION
               'When the "CANCEL" button is pressed, or escape is pressed, or
               ' the dialog is closed, end the dialog
            CASE 104, %IDCANCEL
               EndDialog hDlg, 0
               FUNCTION = 1
               EXIT FUNCTION
         END SELECT
   END SELECT

END FUNCTION


Frederick J. Harris

Way to go Jose!  I just got home and was going to work on it again with the rc file in hand and thought I'd better check to see if you finished it.

Fred

Frank Brübach

thank you both young boys :D

works fine for me too! next time I will try to find more new coding examples. this kind of old and ancient pb things more confuse me than I can learn from with ;) have a nice day, bye, thanks, frank

ps: how to build an resource file *.pbr ? that's new for me!

José Roca

Quote
ps: how to build an resource file *.pbr ? that's new for me!

Load the .rc file in the PB editor and click Compile.

Frank Brübach

#11
ok. I am here also to ask question. And because I am curious and would like to learn more about DLL and creating new functions here my problem: (I have sometimes fun to blame myself ;) ) !

I have trouble simple to calculate "add"  ??? the multiply functions does run as well as I wish.

test_lionbasic.bas code


#COMPILER PBWIN 9
#COMPILE EXE
'--------------------------------------------------------------------
DECLARE FUNCTION MyFunction1 LIB "Lionbasic_DLL.DLL" _
         ALIAS "MyFunction1" (BYVAL Param1 AS LONG) AS LONG
'--------------------------------------------------------------------

'--------------------------------------------------------------------
DECLARE FUNCTION MySub1 LIB "Lionbasic_DLL.DLL" _
         ALIAS "MySub1" (BYVAL Param2 AS LONG) AS LONG
'--------------------------------------------------------------------

'--------------------------------------------------------------------
DECLARE FUNCTION LionBasic_Test LIB "Lionbasic_DLL.DLL" _
         ALIAS "LionBasic_Test" (BYVAL Param3 AS LONG) AS LONG
'--------------------------------------------------------------------

'--------------------------------------------------------------------
DECLARE FUNCTION Colorix LIB "Lionbasic_DLL.DLL" _
         ALIAS "LionBasic_Test" (BYVAL k AS DOUBLE) AS DOUBLE
'--------------------------------------------------------------------

'--------------------------------------------------------------------
DECLARE FUNCTION AddOne LIB "Lionbasic_DLL.DLL" _
         ALIAS "LionBasic_Test" (BYVAL x AS DOUBLE) AS DOUBLE
'--------------------------------------------------------------------


FUNCTION PBMAIN () AS LONG
   LOCAL lRes AS LONG
   LOCAL myResult AS LONG
   LOCAL c AS LONG
   LOCAL z AS LONG
   LOCAL v AS LONG
   LOCAL r AS LONG

   lRes = MyFunction1(lRes)
   c = MySub1(c)
   z = LionBasic_test(z)
   v  = Colorix(v)
   r = Addone(r)

   MSGBOX "SuperHeroes.exe feedback result from first LIONBASIC.DLL:" + STR$(lRes), %MB_OKCANCEL, " ~Lionbasic TestScript " + DATE$
   MSGBOX "Not only SuperHeroes can calculate :) " + STR$(c), %MB_OK, " ~Lionbasic TestScript " + TIME$
   MSGBOX "Does Spiderman goes daily shopping with his girlfriend Anne? " + STR$(z), %MB_ICONQUESTION, " ~Lionbasic TestScript " + TIME$
   MSGBOX "ColorWoman shows you no string: " + STR$(v), %MB_ICONQUESTION, " ~Lionbasic ColorX TestScript " + STR$(v)
   MSGBOX "calculate 2009 + 1: " + STR$(r), %MB_ICONQUESTION, " ~Lionbasic Addone Calc "

END FUNCTION


would be nice to get any answer, how to make "add" in the right way. it's important for me to grasp the general handling of functions and strings! I have got horrible results.

nice friday, servus, frank

José Roca

#12
 
You have a couple of declarations with a wrong alias. They must be:


DECLARE FUNCTION Colorix LIB "Lionbasic_DLL.DLL" _
          ALIAS "Colorix" (BYVAL k AS DOUBLE) AS DOUBLE

DECLARE FUNCTION AddOne LIB "Lionbasic_DLL.DLL" _
          ALIAS "AddOne" (BYVAL x AS DOUBLE) AS DOUBLE


Otherwise, you are calling LionBasic_Test (the function with the name of the alias is what is being called, not Colorix or AddOne).

Frank Brübach

#13
! :)

I see, I see. and one other thing I have found. I have a big cold, so my eyes aren't bright and clear.
here I found another little thing in my lionbasic.dll code side.

code part 1)

FUNCTION AddOne ALIAS "AddOne" (BYVAL x AS DOUBLE, BYVAL y AS DOUBLE) EXPORT AS DOUBLE
 x = 2009
 y = x + 1
 MSGBOX "add one please: " + STR$(y)  ' correct result: 2010 ! :)
END FUNCTION


this one works good finally.

but...

on "testlionbasic.bas" side I have one question again about the result of typing in second "addone":

code part 2):
'--------------------------------------------------------------------
DECLARE FUNCTION AddOne LIB "Lionbasic_DLL.DLL" _
         ALIAS "AddOne" (BYVAL x AS DOUBLE, BYVAL y AS DOUBLE) AS DOUBLE
'--------------------------------------------------------------------


that's also correct by definition except the second "add" result I am producing with following lines:

code part 3)

FUNCTION PBMAIN () AS LONG
...
LOCAL r AS LONG
   r = Addone(r,1)
   MSGBOX "calculate silly things: " + STR$(r,1), %MB_ICONQUESTION, " ~Lionbasic Addone Calc "  


the result of second "add one" is: 1E+6 ! very funny. why ?

I am beating this little beast :D

best regards, thank you josé in advance, frank
ps: whole project as zip file above

José Roca

 
You're corrupting the memory because your declares in the test program doesn't match the ones in the DLL.


DECLARE FUNCTION MySub1 LIB "Lionbasic_DLL.DLL" _
          ALIAS "MySub1" (BYVAL Param2 AS LONG) AS LONG


must be:


DECLARE SUB MySub1 LIB "Lionbasic_DLL.DLL" ALIAS "MySub1" (BYVAL Param2 AS LONG, BYVAL a AS LONG, BYVAL b AS LONG, BYVAL c AS LONG)


and


DECLARE FUNCTION LionBasic_Test LIB "Lionbasic_DLL.DLL" _
          ALIAS "LionBasic_Test" (BYVAL Param3 AS LONG) AS LONG


must be:


DECLARE SUB LionBasic_Test LIB "Lionbasic_DLL.DLL" ALIAS "LionBasic_Test" (BYVAL Param3 AS LONG, BYVAL x AS LONG, BYVAL y AS LONG, BYVAL z AS LONG)