Page 1 of 1

Sudoku DLL

Posted: Wed Oct 19, 2005 3:16 pm
by pantsonhead
Hi there

I found a DLL that generates/solves Sodoku puzzles here:
http://web.telia.com/~u88910365/

I've been able to open the library and examine the functions
but I'm having some problems calling the function.
The function is returning zero but no other errors.

The documentation is pretty thorough so I am hoping somebody can tell me where I'm going wrong (assuming the DLL is not at fault).
I'm pretty sure that I am doing something wrong since I don't use DLLs much.

Code: Select all

extern "C" __declspec(dllimport) int __stdcall Generate(int partGrid[9][9], int diff, int diffMin, int diffMax, int diagonalVers);
Here's my code

Code: Select all

; Sudoku DLL Test
; http://web.telia.com/~u88910365/

Dim grid.l(8,8)
diff.l = 1
diffMin.l=30
diffMax.l=35

;populate the array mostly with zeros
For x = 0 To 8
  For y = 0 To 8
    grid(x,y)=0
  Next 
  grid(0,x)=x+1
Next 


If OpenLibrary(0, "suo_09_eng.dll")
  Debug CountLibraryFunctions(0)
  If ExamineLibraryFunctions(0)
    While NextLibraryFunction() <> 0
      Debug LibraryFunctionName() 
    Wend
  EndIf
  *F = IsFunction(0, "Generate")
  If *F
    Debug *F
    Debug CallCFunctionFast(*F, *grid, *diff,*diffmin, *diffmax, #False)
  EndIf
  CloseLibrary(0)
EndIf

For x = 0 To 8
  For y = 0 To 8
    Debug grid(x,y)
  Next 
Next 
Any help would be greatly appreciated.

Posted: Wed Oct 19, 2005 9:23 pm
by jack
replace

Code: Select all

Debug CallCFunctionFast(*F, *grid, *diff,*diffmin, *diffmax, #False)
with

Code: Select all

Debug CallCFunctionFast(*F, @grid(0,0), diff,diffmin, diffmax, #False)

Posted: Fri Oct 21, 2005 5:43 pm
by pantsonhead
Thanks Jack - your DLL kung fu is strong :)

Posted: Thu Feb 16, 2006 10:56 am
by Michael Vogel
jack wrote:replace

Code: Select all

Debug CallCFunctionFast(*F, *grid, *diff,*diffmin, *diffmax, #False)
with

Code: Select all

Debug CallCFunctionFast(*F, @grid(0,0), diff,diffmin, diffmax, #False)
Be careful when using the actual 1.11 version of the dll - you have to use .w type instead of .l for all variables and there is also an additional parameter now...

btw, it seems that the DLL does NOT produce correct sudokus, I got puzzles with more than one solution, which is not allowed!

Michael

My Sudoku program is here: http://makeashorterlink.com/?M26911A6C