Jump to: navigation, search

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

(Service)
 
(4 intermediate revisions by 2 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 41: Line 43:
 
<source lang="java">
 
<source lang="java">
 
program prog
 
program prog
 +
 +
// variables and constants can be here
 +
 +
// this function is the entrypoint
 
function main()
 
function main()
test(colorEnumeration.RED);
+
printColorName(colorEnumeration.RED);
 
end
 
end
 
 
function test(color colorEnumeration)
+
function printColorName(color colorEnumeration)
 
case (color)
 
case (color)
 
when(colorEnumeration.RED)
 
when(colorEnumeration.RED)
Line 57: Line 63:
 
end
 
end
 
end
 
end
 +
 +
// other functions can go here
 
end
 
end
</source>  
+
</source>
  
 
= <br> Record  =
 
= <br> Record  =

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

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

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