Quick understanding of various macro annotation applications in VC6.0 (with diagram)

Source: Internet
Author: User

Annotations are indispensable to help others or themselves read their own programs. A beautiful program is not about how advanced the technology you use, but about how easy it is to describe.

In the Java IDE environment-Eclispe, there are many annotations, and setting annotations is also very convenient, because currently C ++, Xi, and Eclispe have been uninstalled, for setting comments, Baidu or Google is the only option.

So I am used to the comments of Eclispe, so I tried to try it in VC6.0. How to get familiar with a strange thing is to associate it with your existing knowledge. For example, Java intercepts strings or parses xml. One language has one, and the other language has one.

In addition, in VB. NET, various annotations were added through macro definitions. In contrast, Eclispe settings were preferred, because they were more stupid and directly added macro definitions such as $ Date.

In VC6.0, how does one add common file header comments and Function Method comments.

In the previous blog, I have introduced a method that uses CTRL + \ to comment out a row or multiple rows. I also introduced the use of plug-ins in my previous blog, where there are multiple lines of comments.

Let's take a look at the macro-defined method to add the file header and function comments, that is, the custom script. Hey, it's the script of VB6.0. Seeing that Sub End Sub, pretty friendly.

First, open the VC6.0 program, and choose "Custom"> "additional items" and "macro definition". Select "SAMPLE ".

2. Open the VC6.0 program and select the tool -- macro.

Third, click OK. Various macro Interfaces.

4. Write the annotation name that you need to define in the macro name.. For example, FunctionDesc. Click Edit.

Copy codeThe Code is as follows: Sub FunctionDesc ()

End Sub

PS: You can set the shortcut key for setting comments, similar to CTRL + SHIFT + \ in Java \

Click Options:

Fifth, fill in the vb Script. If your script technology is good, write it yourself. If you want to save trouble, copy or modify it. My function description script is as follows:

Copy codeThe Code is as follows: Sub FunctionDesc ()
Dim doc
Set doc = ActiveDocument
'Be sure active document is a text document
If doc Is Nothing Then
Exit Sub
Elseif doc. Type <> "Text" Then
Exit Sub
End If
Doc. Selection = "/**"
Doc. Selection. NewLine
Doc. Selection = "* function name :"
Doc. Selection. LineDown
Doc. Selection. copy
Doc. Selection. LineUp
Doc. Selection. EndOfLine dsLastText
Doc. Selection = doc. Selection + ""
Doc. Selection. paste
Doc. Selection = "* Function Description :"
Doc. Selection. NewLine
Doc. Selection = "* input parameter :"
Doc. Selection. NewLine
Doc. Selection = "* output parameters :"
Doc. Selection. NewLine
Doc. Selection = "* return value :"
Doc. Selection. LineDown
Doc. Selection. StartOfLine dsFirstText
'Doc. Selection. CharRight dsExtend, 4
Doc. Selection. WordRight dsExtend, 1
Doc. Selection. copy
Doc. Selection. LineUp
Doc. Selection. EndOfLine dsLastText
Doc. Selection = doc. Selection + ""
Doc. Selection. paste
Doc. Selection. NewLine
Doc. Selection = "* Author: lhy"
Doc. Selection. NewLine
Doc. Selection = "* creation date:" + CStr (Now ())
Doc. Selection. NewLine
Doc. Selection = "*/"
End Sub

The file header annotation is similar to the following:Copy codeThe Code is as follows: Sub FileDesc ()

Dim doc
Set doc = ActiveDocument
'Be sure active document is a text document
If doc Is Nothing Then
Exit Sub
Elseif doc. Type <> "Text" Then
Exit Sub
End If

Doc. Selection. MoveTo 1, 1
Doc. Selection. NewLine
Doc. Selection. MoveTo 1, 1
Doc. Selection = "/**"
Doc. Selection. NewLine
Doc. Selection = "* copyright description Contect copyright (c )"
Doc. Selection. NewLine
Doc. Selection = "* file Name:" + ActiveDocument. Name
Doc. Selection. NewLine
Doc. Selection = "* file Description :"
Doc. Selection. NewLine
Doc. Selection = "* creation date:" + CStr (Now ())
Doc. Selection. NewLine
Doc. Selection = "* Author: lhy"
Doc. Selection. NewLine
Doc. Selection = "*/"
End Sub

The effect is as follows:Copy codeThe Code is as follows :/**
* Function name: active (long processInstID, long activityInstID)
* Function Description: The window for activating a specified business function.
* Input parameters: Process instance id and activity instance id
* Output parameters:
* Return value: active
* Author: lhy
* Creation date: 10:26:42
*/
HRESULT active (long processInstID, long activityInstID)
{

// Dynamically load the customer's Dynamic Link Library
// Load the dynamic link library
HINSTANCE hDLL = LoadLibrary ("customerdll. dll ");

// Declare the function pointer
Typedef HRESULT (* activeBusiness) (long, long );
If (hDLL = NULL)
Return S_FALSE;

// Load the function address in the dynamic link library
ActiveBusiness activeBusinessFunc = (activeBusiness) GetProcAddress (hDLL, "active ");
// Determine whether the address is empty
If (activeBusinessFunc = NULL)
Return S_FALSE;

ActiveBusinessFunc (processInstID, activityInstID );

// Release the dynamic link library
FreeLibrary (hDLL );
Return S_ OK;
}

You can change the style, such as // or *. However, this annotation still does not reach Eclispe, because in Eclispe, each parameter is already included in the annotation, so that you can directly explain each parameter in Chinese. In this way, you can manually enter the input parameters. O (zookeeper) o

Another simpler method is as follows::

First, write the script and place it in the installation path Macros. The suffix is DSM. The path to my DSM file is as follows:

2. Select macro files

Third: After the file is loaded, the tool-customization will automatically show up or browse the corresponding file in the corresponding path

Fourth: after the operation is complete, set the shortcut key. Similar to setting the shortcut key in the first method, choose "tool-macro" and select the corresponding macro for setting.

So far, the two most common annotations have been added. Currently, there are two standard annotations I have set. The shortcut keys are all set in java.

In fact, you don't have to lose calm due to worries when encountering unfamiliar things. You can use the previous knowledge to analyze this so-called unfamiliar stuff. There will certainly be a part of your familiarity. The rest of the unfamiliar part, and then slowly explore in a kind of feeling. Even if you are a newbie, you are certainly not as skilled and efficient as a veteran. But when everyone has a newbie, everyone has a veteran.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.