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

From Eclipsepedia

Jump to: navigation, search
(Interface)
(Service)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
This page contains code snippets for custom types.
 +
 
Your custom types are based on these EGL classifiers:  
 
Your custom types are based on these EGL classifiers:  
  
Line 7: Line 9:
  
 
= <br> Enumeration  =
 
= <br> Enumeration  =
 +
 +
The following enumeration defines three possible values. See the [[#Program|example program]] for using this enumeration.
 +
 +
<source lang="java">
 +
enumeration colorEnumeration
 +
RED,
 +
GREEN,
 +
BLUE
 +
end
 +
</source>
  
 
= <br> ExternalType  =
 
= <br> ExternalType  =
Line 14: Line 26:
 
= <br> Interface  =
 
= <br> Interface  =
  
The following Interface type is implemented by the service shown in [[#Service|Service]]:
+
The following Interface type reflects the MyService type shown in [[#Service|Service]]: <source lang="java">
<source lang="java">
+
 
Interface IMyService
 
Interface IMyService
 
   Function calculate(theList INT[] IN)  
 
   Function calculate(theList INT[] IN)  
Line 22: Line 33:
 
   // other function prototypes are here
 
   // other function prototypes are here
 
end
 
end
</source>
+
</source>  
  
 
= <br> Library  =
 
= <br> Library  =
  
 
= <br> Program  =
 
= <br> Program  =
 +
 +
This basic program uses the [[#Enumeration|sample enumeration]].
 +
 +
<source lang="java">
 +
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
 +
</source>
  
 
= <br> Record  =
 
= <br> Record  =
  
= <br> Service =
+
= <br> Service =
  
 
<source lang="java">
 
<source lang="java">
Line 54: Line 94:
  
  
</source>
+
</source> <br> <br><br> ♦ [[EDT:Code snippets|Code snippets main page]] <br>  
<br>
+
<br><br>
+
♦ [[EDT:Code_snippets|Code snippets main page]] <br>
+
 
+
  
 
[[Category:EDT]]
 
[[Category:EDT]]

Latest 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

[edit] Delegate

[edit]
Enumeration

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

enumeration colorEnumeration
	RED,
	GREEN,
	BLUE
end

[edit]
ExternalType

[edit]
Handler

[edit]
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

[edit]
Library

[edit]
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

[edit]
Record

[edit]
Service

Service MyService
 
   // variables and constants can be here
 
   function calculate(myScore Int[] in) returns (Decimal (4,2)) 
 
      numberOfScores, i, mySum Int;
      numberOfScores = myScore.getSize();
 
      for (i from 1 to numberOfScores by 1)
         mySum = myScore[i] + mySum;	       
      end
 
      return(mySum/numberOfScores);
   end
 
   // other functions are here
 
end



Code snippets main page