Mar 312009
 

Registered a project on sourceforge.net yesterday and got approved today, much faster than my previous registration.

This project, as I mentioned before, is intended to migrate previous Delphi(client)/Perl(server) based P2P video chat program to Ada based. It will provide a simple P2P that anyone can make use of it easily, and also a demo project that I can learn my Ada – you know, without a real project it will be impossible to learn a new development tools.

Everything will be GNAT based for sure, seems the only free Ada compiler on Windows and Linux. Client side will use win32ada binding, as it’s a thin layer compare with GWindows/GNATCOM and Claw. vfw will be still the video library, as I think it is not a good time to start working on DirectX, though I’ve read some documents.

Server side will not use many libraries, but I still need gnade as I need a simple local storage support. Actually I should try memory database or just simple key-value pair solution, but for now I will stick with gnade plus sqlite till I get familiar with Ada and can do some more research.

I just uploaded previous Delphi/Perl version to svn (it’s nice that by default we get svn instead of CVS), I’m now learning how to do Win32 program with Ada, stay tuned. 🙂

 Posted by at 19:55
Mar 312009
 

Mother complained quite a lot recently, for all sort of traditional complaints, and my niece emailed me the other day, telling me that she got a boyfriend, but she just does not want to talk to her parents …

Tough day, though it is not worst yet as I can tell, since “there is no worst, just worse”. I’m trying to play good, patting both the old lady and the little girl, compose all those nice words to make them feeling easy.

As a side note, it is proved that those management/communication skils (I used to call them B.S.) are still useful, listen is important, trust is important.

I wish I can get both cases cleared by the end of this week, and if I cannot … I still cannot say “let it be” is a good attitute, but sometime in real life you have to let it be.

I think I will have a long and tough summer break back to Beijing.

 Posted by at 12:54
Mar 302009
 

Here we go, the HelloWorld for Windows written in Ada – put the codes below to a hellowwindows.adb, then run:

gnat make -IC:\GNAT\2008\include\Win32ada -LC:\GNAT\2008\lib\Win32Ada HelloWindows

HelloWindows

sure you need to change the include and library directory to the right one.

Compile it, run it with “hellowindows”, you will see a pop-up window as shown on right.

Here are codes:

-- 我的第一个Windows Ada程序
with Ada.Command_Line;
with Ada.Unchecked_Conversion;
with Interfaces.C;
with System;
with Win32;
with Win32.WinDef;
with Win32.WinMain;
with Win32.WinUser;

procedure HelloWindows is

    function CP (pch: Interfaces.C.CHAR_Array) return Win32.LPCSTR is
        function CSTR_To_Address is new Ada.Unchecked_Conversion(System.Address, Win32.LPCSTR);
    begin
        return CSTR_To_Address(pch(pch'FIRST)'ADDRESS);
    end CP;

    function WinMain( hInstance    : Win32.Windef.HINSTANCE;
	              hPrevInstance: Win32.Windef.HINSTANCE;
	              lpszCmdLine  : Win32.PCSTR;
	              nCmdShow     : Win32.INT) return Win32.UINT is


        szMessage : constant Interfaces.C.CHAR_Array := Interfaces.C.To_C( "你好,Ada世界!", True );
        szTitle   : constant Interfaces.C.CHAR_Array := Interfaces.C.To_C( "第一个Windows Ada程序" );

        hWnd : Win32.Windef.HWND;
        nretVal : Interfaces.C.int;
    begin
        hWnd := Win32.Winuser.GetDesktopWindow;
        nRetVal := Win32.Winuser.MessageBox( hWnd, CP(szMessage), CP(szTitle), Win32.Winuser.MB_OK );
        return 0;
    end WinMain;

begin
    Ada.Command_Line.Set_Exit_Status(
        Ada.Command_Line.Exit_Status(
            WinMain( Win32.Winmain.Get_hInstance,
                     Win32.Winmain.Get_hPrevInstance,
                     Win32.Winmain.Get_lpCmdline,
                     Win32.Winmain.Get_nCmdShow )
        )
    );

end HelloWindows;
 Posted by at 16:52
Mar 302009
 

I just got my new driver license from DMV, and compare the new photo with the photo I took 4 years ago … I’m super fat now.

Actually I know I’m getting fat, but was thinking that’s the problem on tummy only. However, it turned out I’m fat everywhere, at least my face become … ugly, this is the only word in my mind. I have to say, DMV employee’s bad skill of taking photo contribute a lot to the ugly face I have, but if I’m not that fat it will not look like this.

I’ve got my recent numbers on weight, waist, etc. I’m going to track it every week. Sure I won’t post those numbers here as they were treated as top privacy here in US (why? :-W ), but I will let you know how much I manage to reduce, if I make any good progress. 🙂

 Posted by at 10:21
Mar 302009
 

There was an earthquake just now, pretty obvious to me.

I was feeling dizzy at that time, it seems common feeling while having earthquake, I’m not sure if it was caused by shaking, or some sort of “wave”, I will dig around later once get some time.

Tough Monday morning, way too many things to do.

 Posted by at 09:48
Mar 292009
 

GNAVI/GWindows/GNATCOM is a full set of RAD tools for Ada on Windows, seems it was just activated after long inactive state (from 2004 to 2007), it is also based on GNAT.

I was playing with it for couple of hours while I was looking for a good IDE for my Ada learning, but finally I decided to do RAD later, actually, I decided to try to avoid IDE if I can.

Let’s see how far I can go, without IDE. 🙂

 Posted by at 19:16
Mar 292009
 

I know there are handful people are reading my blog, but obviously nobody wants to comment.

Tough, make me feel like talking to wall(s).

 Posted by at 12:35
Mar 292009
 

I’m digging on a beach of Halfmoon Bay – my daughter told me I can stop if I find oil or sea water.

Mission impossible, but I’m trying.

 Posted by at 11:40
Mar 262009
 

Have to say, it is always a pain to deal with charset and encoding while doing development, especially on Windows.

On Linux things are sort of easy though sometime you still need to tweak things, usually I keep everything in UTF8 – source, messages, text files, etc. It may waste some disk spaces (come on, who cares), but it’s way easy to be compatible with every other tools I’m using.

Now back to Windows – by design everything should be Unicode in modern Windows, I think it started from Windows XP or so, but at least Windows Vista should fully support Unicode, isn’t it? However, there are codepage setting for some applications, and you actually cannot control end user’s environment thus make it really hard to build a software that can run on different Windows.

I’m not an expert on this kind of l10n/i18n issue, but I have to face the problem as I’m coding. With gnat-gps, I now set editor etc. to GB2312, with fonts set to some Simplified Chinese fonts, and then make sure the “Command Prompt” uses GB2312/GBK, then I can use Chinese as comment in source file, also I’m able to output Chinese messages in command window.

I’m going to do some Win32 application so command line is not enough, let’s see how far I can go.

 Posted by at 20:58
Mar 262009
 

Well, do a self-assessment – I’m trying to figure out what I have done wrong in the past couple of days.

First, I should not say “this is not my bug”, I should act as before, take the responsibility, despite of what the problem is, and once the bug located, I should not say that (sounds like blaming somebody else), instead, I should solve the problem first, and leave the judgment to so-called management.

Second, I should not hesitate to talk to others – once it is necessary, I should always go to the person directly and get everything cleared. I tend to think about everything carefully before going to any meeting, actually it is not that bad, but sometime it just a waste of effort. Talk (other than email and IM) is part of communication, and it could be the most efficient one.

Third, and could be the most important one, is taking care of physical health. A strong, energic body can always help everything else, and more specifically, help a lot on maintaining mental healthy.

I’m going to resume my exercise today.

 Posted by at 13:18