the fair gds editor pseudoC-C++
Please Sign in

Pseudo C / C++

LayoutEditor supports macros in python or in a C / C++ style. The C/C++ style is very similar to standard C and/or objective C, but not all syntax of it is supported. These syntax will work in LayoutEditor macros:

Data Types

bool boolean datatype, can be true or false

int signed integer, 32bit range (-2147483648 to 2147483647)

double double precision float, +/- 1.7e +/- 308 (~15 digits)

string as an object, please see class string

Example:

   1 int i=0;
   2 double d=0.45;
   3 double f=1E10;
   4 bool b=false;

Arrays: The datatypes int, double and string can be used as array. The resulting variables are identical to the classes stringList, intList and doubleList.

   1 string sl[4];
   2 
   3 sl[0]="string at pos 0";
   4 sl[2]="a further stringstring";
   5 sl[3]="another string";
   6 
   7 sl.clear();
   8 sl.append("one more string");
   9 
  10 // sl will be a stringList with the size 1
  11 

Control Structures

for (start condition;stop condition;step command){commands; beak; continue;}

while (condition) {commands}

do {commands} while (condition)

if (condition) {commands} else {commands} // else is optional

return parameter // leaving the subfunction

switch (parameter) { case parameter: command break; default: command }

break and continue are supported. A break will end the loop. A continue will directly start the next loop iteration. (continue was introduced with version 20141031)

Example:

   1 int i,k;
   2 
   3 for (i=0;i<10;i++){ k=k+5;}
   4 
   5 while (k>10) {k=k/2;}
   6 
   7 do { k++; } while (k<20);
   8 
   9 if (i+k==23) k=k*5;
  10 
  11 switch (i) {
  12 case 0: i=4;
  13         break;
  14 default: i=0;
  15 }

Objective Commands

pointers are supported as in C++, however a new and delete will not work. Please use the class methods to generate new pointer objects. New classes cannot be defined. Just the shipped classes can be used. Conventional function definition can be used in macros as long it is defined before the main function.

Example:

   1 int sqr( int i){
   2 return i*i;
   3 }
   4 
   5 int main(){
   6 int k=sqr(5);
   7 point p(4,5);
   8 
   9 }

Compiler Commands

Two ways to insert comments:

   1 // one line comment
   2 
   3 /* multi line
   4 comment */

to include another file to the macro use:

#include "filename"

Including standard C/C++ header files will not link its standard C/C++ library. To use standard C/C++ extensions, please use its associated classes like math.

Debugging

debug(varName1,varName2,...); will write the variable information to the debug output,

debug.clear(); will clear the debug output,

debug.show(); will open a text editor with the debug output,

debug.saveTo("filename"); will save the debug output to filename.

debug.console(true); will also output debug information to the console, work on Linux and mac only (introduced with version 20140116)

Debugging is global and debug output will remain in the memory after macro termination. So it can be display with a further macro until the LayoutEditor is terminated or the debug output is cleared.

(debugging was introduced with version 20120824)

See also


CategoryTutorial


pseudoC-C++ (last edited 2017-04-01 19:36:23 by JurgenThies)