New topic: Returning a Color Nil
<http://forums.realsoftware.com/viewtopic.php?t=42432> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message Jason_Adams Post subject: Returning a Color NilPosted: Sat Jan 28, 2012 9:46 pm Joined: Fri Nov 10, 2006 4:10 pm Posts: 1306 Location: Michigan, USA Consider the following: Code:Function GetColor(Param As Boolean) As Color If Param Then Return &c00FF00 Else Return Nil End If End Function This function does not work, and for one simple reason: You cannot return a Nil Color, because Color is not an object; it's a module. This, of course, is a cheat. If it were truly a module, you couldn't treat it like an object (setting something to it, returning it, etc.). So, it's "like" a module. My question then, is there a clever trick to returning a function nil that otherwise returns a color? I've thought about returning a variant, but don't like that I'm losing the explicit class (albeit, again, Color isn't a class). Thanks! _________________ Windows 7 Ultimate x64 Windows XP Pro SP3 Ubuntu 11.04 via Virtual Box RS Enterprise 2011r4 Programming Tutorials & Free Projects: http://www.JasonTheAdams.com "Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton Top mauitom Post subject: Re: Returning a Color NilPosted: Sat Jan 28, 2012 10:11 pm Joined: Thu Feb 16, 2006 10:04 pm Posts: 160 Nope. Rb is a strongly typed language and as you say, the Color class is not a Class Object and has no concept of a nil pointer. _________________ Thomas C. REAL.basic Blog http://bigdaddysurf.com/blog/ http://itunes.apple.com/app/maui-raceway-park-app/id459025573?mt=8 Top doofus Post subject: Re: Returning a Color NilPosted: Sun Jan 29, 2012 3:58 am Joined: Thu Sep 10, 2009 2:50 am Posts: 201 Location: Santa Cruz, CA, USA In addition to Variant (I think ok) you could byref the Color and return a bool or use a class that wraps a Color. -d Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 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]
