Hello Bob, I compiled a program including function and it seems to run fine. I suspect that the problem may be elsewhere in your DLL. Perhaps the problem is another function that is overrunning a string buffer and corrupting the stack (containing your automatic variables). Try running a debugger on your code and step through the function. Putting a "watch" on jCount will soon identify if the variable is being altered outside your expected control.
Regards, Warren Vick Europa Technologies Ltd. http://www.europa-tech.com -----Original Message----- From: bob young [mailto:[EMAIL PROTECTED] Sent: 10 October 2005 16:27 To: mapinfo-l@lists.directionsmag.com Subject: MI-L Calling all C programmers - help with bug Dear List If any C programmers on the list can see a bug in this code I would be most grateful! The code has been cut from a much larger program. The code stays inside the while loop as the line jCount++ does not get executed for some reason. I have extracted the code from an EXE and built in a DLL that can be called from MapBasic or VB and each time it stays in loop. If the code is changed slightly it works, but as is - will not. Any one with any ideas?? Code as follows #include <stdlib.h> #include <string.h> long Example1() { long iFlag = 0; long lnOranges = 0; long lnApple[100]; long jCount = 0; long lnThreshold = 0; char lsString[100]; lnOranges = 2; lnThreshold = 1; for (iFlag = 0; iFlag < 2;iFlag++) { if (lnOranges> 1) { jCount = 0; while (jCount < lnThreshold) { strcpy(lsString,"string"); lnApple[jCount] = 0; jCount++; } } else { lnThreshold = 1; } } return 9; } -- bob young --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 18189 --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 18190