Aug 31, 2010

OMG - VIM

Yup, today is the day I started liking VIM
=)

This is kinda funny though, as my previous experience with Visual Studio is much much better than using VIM, but somehow, it just feel right.

Actually, I think that there is something in VIM that all programmer like: the ability to NOT follow convention. Surely, navigating with H, J, K, L is difficult, but why follow everyone else and use arrow key =)). After all, they are just conventions, not compulsory!

Nevertheless, I should start posting something about coding here:

This is an old habit of mine ever since I use Windows: CTRL - S to save.
In VIM, this actually makes the program hangs. However, according to the developers, this only "stop the data from arriving so that you can stop a fast scrolling display to look at it" (Refer Here)

To compensate for that, just do a CTRL - Q.

This actually helps a lot since I don't have to disconnect from my Unix server in school again :)

Aug 25, 2010

Change the Project's Directory & couldn't find "stdafx.h"

Last time I built a working program with a GUI.
After that, I saved it, changed the DIRECTORY NAME that it was in ( so, originally, it was in [Original name]/[Original name], but i changed the directory to [New name]/[Original name] ).
Then, when I go back and run the program again, I got error: 
fatal error C1093: API call 'ImportFile' failed '0x80070003' : ErrorMessage: The system cannot find the path specified.
it seems quite impossible, since "stdafx.h" is already there in my project.
Confused!!!!

However, after a while, I found some article online and tried to imitate it, and the issue is solved :)
Here is what I do:
  • Goto Build - Clean Solution
  • Build & Run again
Hope this help anyone catching it later

The new C++

Phew, I finished getting a Win Form App, included with a user-built class, running. It was quite a pain, especially if you have already got used to the comfort of Command Line Interface (CLI) used for studying C++ or GUI development with C#. C++ is somewhere in between, and well, a  bit hard to catch up

After spending around 5 hours on this, I found some of the following interesting features:
  • In C++, whenever you create a Win Form project (all I know beside Win32 Console right now), you will automatically have a stdafx.h & stdafx.cpp to do the standard #include operation for all the code file. Any special #include can be implemented in stdafx.h
    Sample:


    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently

    #pragma once

    // TODO: reference additional headers your program requires here
    //#include <string>
    #include "SimpleException.h"
  • Class ends with ";" (semi-colon). I forgot about that and wasted a few hours.
  • C++ can also have garbage collection like C#. Fot that, you must follow a special syntax called "managed C++":


    ref class SimpleException
        {
        public:
        //constructor
            //default
            SimpleException(String^);
        //accessor
            //get error message
            String ^GetError();
        private:
            String ^_errMsg;
        }
  • In managed C++, instead of using value typed variables, the code uses handler (which is still different from unmanaged C++), something like pointer. However, instead of using the asterisk character (*), we use  the caret character '^' to denote these managed objects. Plus when declaring structures & classes, we also use the "ref" keyword (since all the structure / classes are "handler" by definition)
Okay, this is the code for referencing:
Download