Difference between revisions of "EDT:Working with custom types"

From Eclipsepedia

Jump to: navigation, search
(Service)
(Service)
Line 72: Line 72:
 
= <br> Service  =
 
= <br> Service  =
  
<source lang="java" line="GESHI_FANCY_LINE_NUMBERS">
+
<source lang="java" line="GESHI_NORMAL_LINE_NUMBERS">
 
Service MyService
 
Service MyService
  

Revision as of 15:12, 6 March 2012

This page contains code snippets for custom types.

Your custom types are based on these EGL classifiers:

Delegate, Enumeration, ExternalType, Handler,
Interface, Library, Program, Record, Service

Contents

Delegate


Enumeration

The following enumeration defines three possible values. See the example program for using this enumeration.

enumeration colorEnumeration
	RED,
	GREEN,
	BLUE
end


ExternalType


Handler


Interface

The following Interface type reflects the MyService type shown in Service:
Interface IMyService
   Function calculate(theList INT[] IN) 
            returns(BIN (4,2));
 
   // other function prototypes are here
end


Library


Program

This basic program uses the sample enumeration.

program prog
 
	// variables and constants can be here
 
	// this function is the entrypoint
	function main()
		printColorName(colorEnumeration.RED);
	end
 
	function printColorName(color colorEnumeration)
		case (color)
			when(colorEnumeration.RED)
				syslib.writestdout("red");
			when(colorEnumeration.GREEN)
				syslib.writestdout("green");
			when(colorEnumeration.BLUE)
				syslib.writestdout("blue");
			otherwise
				syslib.writestdout("unknown");
		end
	end
 
	// other functions can go here
end


Record


Service

  1. Service MyService
  2.  
  3.    // variables and constants can be here
  4.  
  5.    function calculate(myScore Int[] in) returns (Decimal (4,2)) 
  6.  
  7.       numberOfScores, i, mySum Int;
  8.       numberOfScores = myScore.getSize();
  9.  
  10.       for (i from 1 to numberOfScores by 1)
  11.          mySum = myScore[i] + mySum;	       
  12.       end
  13.  
  14.       return(mySum/numberOfScores);
  15.    end
  16.  
  17.    // other functions are here
  18.  
  19. end



Code snippets main page