Tuesday, July 5, 2016

Refactoring

My egg foo young from lunch was too much, so I left it to snack on later. Chinese food doesn't sit well.

Anyway I got to thinking about my idea to put all OS dependencies in one file, but decided to split it in two because win32 has hundreds of possible calls and breaking those out into a separate file allows code reuse on future projects.

Euphoria is a bit manic. When it generates an error file it sometimes points you in the wrong direction. I had implemented LoadIcon and LoadCursor and they were working fine. Then I added CreateWindow and LoadIcon blew up. Wrong count of parameters it said which I hadn't changed. So I stubbed it out, after which it started complaining about LoadCursor, so I stubbed that out as well.

Then I was shocked that it compiled and seemed to run fine. That should not have happened. Somehow I'm sure I'm corrupting memory somewhere but haven't a clue how I'm going to track that down.

I'm not sure about parameter passing from Euphoria to C either. Euphoria has two routines that work together but take their parameters in reverse order. To pass strings to C you have to allocate memory and pass a pointer. The thing is I'm not confident I'm passing the right size parameters. Everything is working, but I'm flying blind at the moment. Euphoria has a thing called a sequence which is not a contiguous array. I understand it's referenced by a pointer, but how does C know anything about the structure of a sequence? It cant, but passing them as parameters seems to work fine. I'm going to have to dig a bit into the calling functions so I can better understand what's going on.

I'm shocked to discover references I used back when I was a working programmer are no longer online. I've got Petzold in PowerBASIC and everything else in C (I do not like C++) which I then have to translate into Euphoria which has documentation that doesn't keep up with the changes in the development of the language. I want a function dictionary with snippets and something definitive on type sizes. The information just isn't in one place as it should be. I downloaded win32.hlp and win32.chm but neither of them gave me access to their info! Those were both large downloads but appear empty when I tried to reference them. The help file was particularly outragious since it did load but wouldn't show me anything. That means Microsoft intentionally made help files obsolete starting with windows 8. How can I know that? Because the help files do load, they just don't work beyond that. So Microsoft removed the functioning code from the OS and intentionally replaced it.

I've got an early appointment with my wound care guy in about 5 hours from now, so I'd better get some sleep.

Update: Well, I got a refreshing 3 hours of sleep last night. I'm good to go. Across the street is a field filled with donkeys and llamas. The donkeys think they are roosters. They put on quite a racket just before dawn. I've got another two hours until my appointment which only takes about 15 minutes, then I'm back to coding. Right now it's a bit of drudgery, but as I get the foundation built the rest will be a lot more fun.

No comments: