logo

MacroExample1

logo
welcome: Please Sign in

the fair gds editor


location: MacroExample1

Concrete examples are often more plastic than any long description of the language and structure. So here are some example macros to get an understanding on things possible with macros in the LayoutEditor.

Macro Example 1

This example shows some basic C++ features and how these features are used in macros.

   1 #!/usr/bin/layout
   2 #name=#1: Syntax
   3 #help=Helptext for Sample 1
   4 
   5 int main(){
   6 
   7   // This is a comment
   8 
   9   /* This is 
  10   a multiline
  11   Comment
  12   */
  13 
  14   // possible typ
  15   int i;
  16   i=6;
  17 
  18   bool b;
  19   b=true;
  20 
  21   double d;
  22   d=6.2345;
  23 
  24   string s;
  25   s= "This is a test!\n";
  26 
  27   point p;
  28   p.setX(1000);
  29   p.setY(900);
  30 
  31   pointArray pa;
  32   pa.resize(1);
  33   pa.setPoint(0,p);
  34 
  35 
  36 
  37   // if command
  38   if (i==6) s+="i is equal to 6";
  39   else d+=i;
  40   
  41   // for loop
  42   int k;
  43   for (k=1; k<=3 ; k++){
  44         i+=k;
  45   }
  46 
  47   // while loop
  48   while (k<5){
  49         k++;
  50   }
  51 
  52   // do {} while loop
  53   do {
  54         k++;
  55   }while (k<10);
  56 
  57   return 0;
  58 }

See also


CategoryMacro

MacroExample1 (last edited 2012-04-15 10:41:02 by JürgenThies)