Command description for GDexpi add in.

The GDexpi works by parsing a file that has som macros defined in it. These macros can later be expanded in a edit window for Visual studio.

Macros defined in file that is parsed, has to be written after sertain rules that makes the GDexpi possible to parse them. It is very similar to define a macro in C++ or C with some extensions.

If you have any functionallity that you would like to be added for the GDexpi add-in, pleace mail to: Gorep development


#define

This command is used to define a new macro. You can only define one macro for a name. And the name is case sensetive. "MACRO1" and "Macro1" is two different names. Each macro can have parameters and those can be used in the macro text.

Example:
#define FIRST This is the first macro

If you type "FIRST" in the editor and select it for expansion it will be replaced with "This is the first macro".

Example:
#define Second( text ) This is a text

Type "Second( apple )" in a edit window and it will be expanded to "This is a apple"

More examples:

Macro: #define Hi Hi! How are you
Type: Hi
Expanded text: How are you
 
Macro: #define Hi( name ) Hello name ! How are you
Type: Hi( Marie )
Expanded text: Hello Marie ! How are you
 
Macro: #define Hi(name) Hello name ! How are you
Type: Hi( "Mrs. Marie" )
Expanded text: Hello Mrs. Marie ! How are you
If the word contains space characters or some other characters that is not in the alphabet or a digit. You need to put the text between "text here".
Macro: #define many(one, two, three ) This macro contains one two three
Type: many( first, second, "last one" )
Expanded text: This macro contains first second last one

 

You can set some attributes to the #define keyword. In version 1.0 of the GDexpi addin there are two attributes that can be used. And the attributes has to be written between [] just after the #define key word. Attributes that can be used is "indent" and "escape". Indent means that the macro text is indented in the editor the number of spaces that is selected before the macro starts. If escape is set, some sequences in macro text is replaced with other characters. "\n" becomes newe-line, "\t" becomes a tab-character and "\\" becomes a single slash

Example:

#define[escape] Sample This\nis\na\ntext

If you type "Sample" and expand it the output text is:
This
is
a
text

As you can see the "\n" sequence will be replaced with a new-line.

Some more examples:

Macro: #define[indent,escape] TEXT This\n is a text
Type:    TEXT
Expanded text:    This
    is a text
 
Macro: #define[escape] MACRO( name ) \nHello\nname
Type: MACRO( Smith )
Expanded text:
Hello
Smith

 


#start and #end

If the macro text is large or for some other reason. It can be placed between #start and #end key word.

 

Macro: #define[escape] MACRO
#start
You can write text here between the keywords\n that starts and ends the macro.
#end
Type: MACRO
Expanded text: You can write text here between the keywords
that starts and ends the macro.

 


#if and #elseif

This keyword is a bit complicated but is very usefull to make the macros a lot more powerfull. Often when a macro is done you want it to create a output that is dependent on the parameters that are sent to the macro. #if and #endif only works with macros that has parameters in them. #endif only works if it is placed after a #if keyword

Example:

#define text ( check )
#start
Here we have a macro that is checks the parameter that is sent to macro
#if( check )[ check parameter is sent to macro]
#end

If you type "text" and expand it the output will be "Here we have a macro that is checks the parameter that is sent to macro". Then try to type "text( hi )" And you will get the output "Here we have a macro that is checks the parameter that is sent to macro check parameter is sent to macro". So the output is dependent on if the parameter that is sent to macro.

It is also possible to check if a parameter is equal to some word, starts with a specified character sequence, is not equal to a word or has a character sequense in it.

 

Macro: #define[escape] Print( text )
#start
Print some text:\n
#if( text = test )[equalt to test]#elseif( text =* g)[starts with a g]#elseif( text =? x )[found a x character in parameter]
#end
Type: Print( x )
Expanded text: Print some text:
found a x character in parameter
Type: Print
Expanded text: Print some text:
Type: Print( test )
Expanded text: Print some text:
equalt to test
 
Macro: #define many( a, b, c )
#start
#if( a )[_a is valid and is equal to a]
#if( b )[_b is valid and is equal to b]
#if( c )[_c is valid and is equal to c]
#end
Type: many( ,, Hi )
Expanded text: _c is valid and is equal to Hi
Type: many( one, two, three )
Expanded text: _a is valid and is equal to one _b is valid and is equal to two _c is valid and is equal to three
Type: many( "This is a longer parameter" )
Expanded text: _a is valid and is equal to This is a longer parameter
As you can se in one sample here there is no need to send all parameters to a macro. There is no need to write the macro with all parameters because they are allways optional.
Macro: #define [escape,indent] TEST( what )
#start
#if( what =? A )[Found an \"A\" in parameter ]
#if( what =! A )[Parameter is not equal to A]
#end
Type:    TEST( AA )
Expanded text:    Found an "AA" in parameter Parameter is not equal to AA]
 
Macro: #define[escape] TEST( x )
#start
#if( x =? A )[Found A in parameter] #elseif( x =? B )[Found B i parameter] #elseif( x =* C )[starts with C]
#end
Type: TEST( AB )
Expanded text: Found A in parameter
Type: TEST C
Expanded text: starts with C
Type: TEST( CB )
Expanded text: Found B i parameter]

 


## (Tokenpaste)

Token paste are used when a parameter is a part of another word and should be expanded. If you have a name and the end of the name is set from a parameter there has to be some way to tell that there is a paramter in a word. This is done by type tokenpaste sequence (##).

Example:

#define extend( name ) extended word is aaaa##namebbbb

Then type extend(" hello") in editor and it will be expanded to "extended word is aaaa hellobbbb". As you can se the name is inserted into another word. This is could often be usefull when some macros should be expanded.