1. Wrapping Win32 stuff

--==========116684689==========

Hi, all.

I have a C program that I just typed in out of a book.  It is supposed to 
demonstrate use of Win32 API file functions.  I wanted to try this out, 
then try wrapping some Win32 stuff with Euphoria.

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


--==========116684689==========
Content-Type: application/octet-stream; name="fileio.c"
Content-Transfer-Encoding: base64

new topic     » topic index » view message » categorize

2. Re: Wrapping Win32 stuff

I think I can translate it for you (maybe!)
I have to finish up my Dynamic Menu translation (finishing now)
I could have it together Mon or Tues....

Euman

> Hi, all.
> 
> I have a C program that I just typed in out of a book.  It is supposed to 
> demonstrate use of Win32 API file functions.  I wanted to try this out, 
> then try wrapping some Win32 stuff with Euphoria.
> 
> 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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Wrapping Win32 stuff

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: Wrapping Win32 stuff

Travis,

Thank you for pointing out my typos.  Careless.  Don't be concerned about 
having to get me away from C!  That foul language is what turned me off of 
programming in the first place.  So unnecessarily cryptic.  Euphoria is my 
first choice for any project.

Nonetheless, I do want to get into wrapping some C functions, so I can add 
to the libraries and improve the robustness of Euphoria.  I thought I'd 
start by taking a simple C program and converting it...

I still couldn't get my fileio.c to compile in the IDE.  It didn't just 
seem to have a way to load a .C file, and compile it.  It had to make a 
project file and add some additional files and a form for a UI, none of 
which I wanted.  The whole thing reminded me of MS FrontPage.  That program 
is just too overblown to just go in and make a single, simple web page... 
But I digress.

So I opened up a command line, and found that "bcc32 -tW fileio.c" got it 
compiled and working perfectly.  On to the wrapping part!

--Ted

--On Sunday, April 22, 2001 11:35 PM -0500 Travis Beaty 
<travisbeaty at arn.net> wrote:

>
>
> 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.
<snip>

>
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu