[futurebasic] Re: [FB] Question on Integer(%) and Long Integer(!): Now a bit of trivia.

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2002 : Group Archive : Group : All Groups

From: Heather Donahue <maclists@...>
Date: Tue, 12 Nov 2002 12:38:46 -0800
On 11/12/02 12:14 PM, "DFast@..." <DFast@...> wrote:

> OK, so I changed my next program to DIM all variables. I am also utilizing
> PRINT USING to line things up and to format the correct number of decimal
> places. I am getting a "rounding" effect that appears to wipe out the
> decimal value; ie, behaving as INTEGER instead of DOUBLE. Again, my thinking
> was incorrect. Evidently the AS DOUBLE only applies to the single,
> immediately preceding variable.
> 
> =======================
> BEGIN GLOBALS
> DIM Inches,Feet,Yards,Miles AS DOUBLE
> DIM Centimeters,Decimeters,Meters,Kilometers AS DOUBLE
> DIM PROGRAM$
> END GLOBALS
> =======================
> 
> It appears that this is NOT equivalent to:
> 
> =======================
> BEGIN GLOBALS
> DIM AS DOUBLE Inches,Feet,Yards,Miles
> DIM AS DOUBLE Centimeters,Decimeters,Meters,Kilometers
> DIM PROGRAM$
> END GLOBALS
> =======================
> 
> This works correctly.

I wasn't sure so I checked the reference:

> Effective with Release 3, a new syntax may be used with DIM.
> DIM AS LONG a,b,c
> DIM AS RECT myRect
> The DIM AS syntax indicates that all variables that follow are of the same
> type and size.
> This is different from DIM a AS LONG which provides variable specification for
> only one dimensioned variable in the statement.


I prefer the DIM AS syntax now, it's closer to the C syntax, which saves my
brain a little bit.  I wish we could do as C does here:

C:
    int myVar = 100;

FB^3:
    word myVar = 100

instead of:
    word myVar: myVar = 100

Just seems redundant.