New topic: 

Computed Constants

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

       Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic         Author  
Message       JaceNicklien           Post subject: Computed ConstantsPosted: 
Fri Dec 04, 2009 12:30 pm                               
Joined: Sat Nov 17, 2007 1:53 pm
Posts: 14              Is there a way in RB to use a constant in a constant?  
An example would be...

Const RADIANS  defined as  PI/180

Where PI is also defined as a constant   
                            Top                mhartman           Post subject: 
Re: Computed ConstantsPosted: Fri Dec 04, 2009 1:25 pm                        
Joined: Sun Mar 26, 2006 12:51 am
Posts: 45
Location: California              Hello

You could establish a global constant called PI such as:

Const PI=3.14159265358979323846264338327950

Then use this value to establish other contants such as:
Dim x As Double
x=Acos(.5)*180/PI   
                            Top               Phil M           Post subject: 
Re: Computed ConstantsPosted: Fri Dec 04, 2009 2:10 pm                        
Joined: Fri Sep 30, 2005 12:18 pm
Posts: 570              Even if you could integrate other constants inside 
constants, they are not macros and you would not be able to perform 
calculations like other languages have.  

In the case of Radians, pre-calculate the values yourself:

Which PI/180 is really just 0.017453292519943.
And the inverse being 180/PI = 10313.240312354992529.
Basically set up 3 constants if you include PI.

I understand your point though, it would be very nice to allow constants inside 
constants.  Here is an example where they could be used.

Const APPNAME = "My App"
Const WARNING = "Warning: &CONST_APPNAME must be shut down."   
                            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]

Reply via email to