Re: Wrapping Win32 stuff
- Posted by Travis Beaty <travisbeaty at arn.net> Apr 22, 2001
- 405 views
Hello Mr. Fines Ted Fines wrote: > My C abilities are pretty low. Well, below pretty low, actually. The > program just runs (supposedly) then quits. I'm using Borland's C++ Builder > 5. No errors are reported. No messages of any kind. Yet the code is > supposed to display a series of message boxes. Any help? Attached is the > code. I have a feeling the code is the function, but the actual calling of > the function doesn't happen, and I don't know how to do it. > > Thanks, > Ted > Well, congratulations. C has bitten you in the butt. I've been there. That's why I'm such an Eu fanatic. You had a couple of typos in your code that you probably didn't notice since you're not real familiar with Windows API calls in C. First of all, remember that C, like Euphoria, is case sensitive -- it will not consider foo() and Foo() to be the same function. On line 51, ShowWIndow(hwnd,nWinMode); should read: ShowWindow(hwnd, nWinMode); On line 57, TranhslateMessage(&msg); should read: TranslateMessage(&msg); On line 75, getCurrentDirectory(sizeof(buf),buf); should read: GetCurrentDirectory(sizeof(buf), buf); Make these changes, and your program will work correctly. This, Mr. Fines, is one of the **major** strengths that Euphoria has over C. If you type in a C function which it doesn't know about, such as getCurrentDirectory(), it quietly assumes that you'll introduce it later, and goes on faith that it exists. If you set the compiler correctly, it will warn you that you haven't declared it (aka. "this function has no prototype," or something like that), but it will still compile and link it. When you run the program, C then idiotically calls a function which doesn't exist, and the program goes "kaboom." Euphoria, on the other hand, will see that getCurrentDirectory() doesn't exist, and will stop right then and there, which saves the programmer from the trouble, worry, and six packages of antacid as he wonders why the heck the good code is being bad. Also, notice that your program was flawed, but the compiler said nothing. The compiled program just said to itself "Aw hell," and vanished. Nothing to tell you what happened. Euphoria, on the other hand, is extremely good about telling you what happened to cause the crash. -- Travis --