EDT:Working with custom types

From Eclipsepedia

Revision as of 16:26, 20 February 2012 by Jspadea.us.ibm.com (Talk | contribs)

Jump to: navigation, search

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
	function main()
		test(colorEnumeration.RED);
	end
 
	function test(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
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