I created a dll to convert a date string into the unique day number. I use this dll in several programs without any problems. However, one program causes the "windows must close" message after running the program 2 or three times in succession without closing the program. The details in the windows error seems to point to my dll.
This is the declare I use for the dll.
DECLARE FUNCTION JULIANDLL LIB "Julian.dll" ALIAS "Juliandate" (BYREF userdate AS STRING) AS LONG
and here is the dll code
I have written test code to verify that all the date strings sent to dll are correct. All dates are generated programatically in another program.
I can usually fix errors with the PB tools, but "trace" and "debug display" show no errors. If someone would look at the compilable code in the zip file, I would certainly appreciate any help.
Thanks,
John Tate
This is the declare I use for the dll.
DECLARE FUNCTION JULIANDLL LIB "Julian.dll" ALIAS "Juliandate" (BYREF userdate AS STRING) AS LONG
and here is the dll code
Code:
#COMPILE DLL #DIM ALL %USEMACROS = 1 #INCLUDE "Win32API.inc" GLOBAL ghInstance AS DWORD '------------------------------------------------------------------------------- ' 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. ghInstance = 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 Juliandate ALIAS "Juliandate" (BYREF userdate AS STRING) EXPORT AS LONG LOCAL MONTH ,DAY ,YEAR,ya,cf,yf,mf,century AS LONG LOCAL MJULIAN AS LONG LOCAL m,d,y,jdn,a AS LONG LOCAL UD() AS STRING,x AS LONG x = PARSECOUNT(USERDATE,ANY "./-") REDIM Ud$(1 TO x) PARSE userdate,Ud$(),ANY",./-" m = VAL(Ud$(1)):d = VAL(Ud$(2)) :y = VAL(Ud$(3)) month = VAL(Ud$(1)):day = VAL(Ud$(2)) :year = VAL(Ud$(3)) IF year => 80 AND year <100 THEN year = year +1900 IF year <80 THEN year = year + 2000 a = (14 - month)\12 y = year + 4800 -a m = month +(12*a) - 3 JDN = d +((153*m)+2)\5 + (365*y) + (y\4) - (y\100) +(y\400) - 32045 ' END IF FUNCTION = jdn END FUNCTION
I can usually fix errors with the PB tools, but "trace" and "debug display" show no errors. If someone would look at the compilable code in the zip file, I would certainly appreciate any help.
Thanks,
John Tate
Comment