New topic: 

Not quite Overloading.

<http://forums.realsoftware.com/viewtopic.php?t=45749>

         Page 1 of 1
   [ 4 posts ]                 Previous topic | Next topic          Author  
Message        DaveS          Post subject: Not quite Overloading.Posted: Sun 
Oct 28, 2012 7:22 pm                                 
Joined: Sun Aug 05, 2007 10:46 am
Posts: 4202
Location: San Diego, CA                I know what overloading is and use it 
where it applys.... but I have a similar situation but not sure if it can even 
be done or not.

I want to create a FUNCTION and a PROCEDURE with the same name (think MSGBOX)

if you say  x=MSGBOX("msg",btns) it is a FUNCTION and returns a value
but you can also say  MSGBOX "msg",btns and it is a PROCEDURE and does NOT 
return a value

Normal overloading requires that the parameter signatures be different, but 
here there is no difference in the INPUT parameters, just the existance or lack 
of an OUTPUT one.

Anybody got an idea ... can this be done?  

I was hoping for something like this

FUNCTION foo(arg1 as string, arg2 as integer, arg3 as integer=0) as integer
  .... code
  return some_value
END FUNCTION

SUB foo(arg1 as string, arg2 as integer, arg3 as integer=0)
  CALL foo(arg1,arg2,arg3)
END SUB


EDIT
a kludge Band-aid..... I made one of the arguments in the FUNCTION INT16 
instead of INTEGER.....      
_________________
Dave Sisemore
MacPro, OSX Lion 10.7.4 RB2012r1
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                charonn0          Post subject: 
Re: Not quite Overloading.Posted: Sun Oct 28, 2012 7:28 pm                      
           
Joined: Mon Apr 02, 2007 2:08 am
Posts: 946
Location: San Francisco, CA, USA                You're using the Call keyword, 
which makes it ambiguous which method you're calling, by discarding the return 
value.      
_________________
Boredom Software  
                             Top                timhare          Post subject: 
Re: Not quite Overloading.Posted: Sun Oct 28, 2012 10:47 pm                     
    
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11765
Location: Portland, OR  USA                I do this frequently.  As charonn0 
says, drop the CALL keyword and everything works fine.
SUB foo(arg1 as string, arg2 as integer, arg3 as integer=0)
  dim x as integer
  x = foo(arg1,arg2,arg3)
END SUB
   
                             Top                DaveS          Post subject: 
Re: Not quite Overloading.Posted: Sun Oct 28, 2012 11:12 pm                     
            
Joined: Sun Aug 05, 2007 10:46 am
Posts: 4202
Location: San Diego, CA                Thanks....      
_________________
Dave Sisemore
MacPro, OSX Lion 10.7.4 RB2012r1
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 4 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to