Sudoku DLL

Just starting out? Need help? Post your questions and find answers here.
pantsonhead
User
User
Posts: 39
Joined: Fri Mar 26, 2004 1:47 pm
Location: London, UK
Contact:

Sudoku DLL

Post 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.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post 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)
pantsonhead
User
User
Posts: 39
Joined: Fri Mar 26, 2004 1:47 pm
Location: London, UK
Contact:

Post by pantsonhead »

Thanks Jack - your DLL kung fu is strong :)
User avatar
Michael Vogel
Addict
Addict
Posts: 2811
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post 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
Post Reply