There are many examples of this within the DynAPI.  Here's an example of 
some code form my version that I use:

DynEvent.Drag.setBoundary=function(dlyr) {
        var a=arguments;
        switch(a.length) {
                case 1 : dlyr.dragBoundary='parent'; break;
                case 2 : dlyr.dragBoundary=a[1]; break;
                case 5 : dlyr.dragBoundary=[a[1],a[2],a[3],a[4]];
        };
        return;
};

You can see that by testing the value of arguments.length, it is possible to 
behave in a different manner depending on the number of arguments passed to 
a method / function.

>From: "Todd Marshall" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Subject: [Dynapi-Help] overloaded function calls
>Date: Tue, 18 Dec 2001 11:38:39 -0500
>
>What is the preferred, or correct, method to implement overloaded
>function calls
>I.E. having the same "method" work differently depending on different
>parameters.
>
>For Example:
>I might want a      layer(x1,y1,x2,y2)
>Or I might want a  layer(x1,y1,width,height)
>
>I can think of two ways to do it:
>1) layer(x1,y1,width,height,x2,y2) and call it layer(x1,y1,,,w,y)  or
>layer(x1,y1,x2,y2,,,)
>
>2) use a flag layer(a,b,c,d,"usex2y2") and layer(a,b,c,d,"useWidths")
>and check the final parameter to determine which one I want.
>
>Perhaps you need to use derived classes "layerCoords" and "layerWidths"
>???
>
>Suggestions? I think there are examples of this in the DynAPI itself???
>Thanks,
>Todd.
>
>
>
>_______________________________________________
>Dynapi-Help mailing list
>[EMAIL PROTECTED]
>https://lists.sourceforge.net/lists/listinfo/dynapi-help
>


_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dynapi-help

Reply via email to