ftp.nice.ch/pub/next/science/medicine/BMI.1.2.NIHS.bs.tar.gz#/BMI1.2/Source/BMICalcObject.m

This is BMICalcObject.m in view mode; [Download] [Up]

#import "BMICalcObject.h"

@implementation BMICalcObject

- Calc:sender
{

// Decalare Variables

    float weight;
    float height;
    float index;   
    float gender;
    float agegroup;

// Assign variables
       
        height = [Height floatValue];
	weight = [Weight floatValue];
	
// Calculatate BMI and display BMI

	index = (weight/(height*height));

        // Display BMI index number
	[Index setDoubleValue:index];// Display result
	[Index display];
	[IndexGauge setDoubleValue:index];// Display result
	[IndexGauge display];


	// Gender Male = 1, female = 2
    	gender = [GenderButton selectedTag]; 

	// Age Group < 18 = 1, 20-29 = 2, >29 = 3
    	agegroup = [AgeGroupButton selectedTag];
   
        // Figure out in what category the person is in
        // and display the status for that person.

        // Below 18, male, normal
   	if ((agegroup == 1) && (gender == 1) && (index < 22))	
	{
	[Status setStringValue:"Normal"];
        [Status setTextColor:NX_COLORGREEN];
	};

        // Below 18, male, overweight
   	if ((agegroup == 1) && (gender == 1) && (index > 22))	
	{
	[Status setStringValue:"Over weight"];
        [Status setTextColor:NX_COLORRED];
	};

        // Below 18, female, normal
   	if ((agegroup == 1) && (gender == 2) && (index < 20))	
	{
	[Status setStringValue:"Normal"];
        [Status setTextColor:NX_COLORGREEN];
	};

        // Below 18, female, overweight
   	if ((agegroup == 1) && (gender == 2) && (index > 20))	
	{
	[Status setStringValue:"Over weight"];
        [Status setTextColor:NX_COLORRED];
	};



        // 20-29, Male, under weight
   	if ((agegroup == 2) && (gender == 1) && (index < 20))	
	{
	[Status setStringValue:"Under weight"];
        [Status setTextColor:NX_COLORYELLOW];
	};

        // 20-29, male, normal
   	if ((agegroup == 2) && (gender == 1) && (index < 27.8) && (index > 20))
	{
	[Status setStringValue:"Normal"];
        [Status setTextColor:NX_COLORGREEN];
	};

        // 20-29, male, over weight
   	if ((agegroup == 2) && (gender == 1) && (index > 27.8))
	{
	[Status setStringValue:"Over weight"];
        [Status setTextColor:NX_COLORRED];
	};

        // 20-29, female, under weight
   	if ((agegroup == 2) && (gender == 2) && (index < 20))	
	{
	[Status setStringValue:"Under weight"];
        [Status setTextColor:NX_COLORYELLOW];
	};


        // 20-29, female, normal
   	if ((agegroup == 2) && (gender == 2) && (index < 27.3) && (index > 20))
	{
	[Status setStringValue:"Normal"];
        [Status setTextColor:NX_COLORGREEN];
	};

        // 20-29, female, over weight
   	if ((agegroup == 2) && (gender == 2) && (index > 27.3))
	{
	[Status setStringValue:"Over weight"];
        [Status setTextColor:NX_COLORRED];
	};



        // Over 29, Male, under weight
   	if ((agegroup == 3) && (gender == 1) && (index < 20))	
	{
	[Status setStringValue:"Under weight"];
        [Status setTextColor:NX_COLORYELLOW];
	};


        // Over 29, male, normal
   	if ((agegroup == 3) && (gender == 1) && (index < 25) && (index > 20))
	{
	[Status setStringValue:"Normal"];
        [Status setTextColor:NX_COLORGREEN];
	};

        // Over 29, male, over weight
   	if ((agegroup == 3) && (gender == 1) && (index > 25))
	{
	[Status setStringValue:"Over weight"];
        [Status setTextColor:NX_COLORRED];
	};

        // Over 29, female, under weight
   	if ((agegroup == 3) && (gender == 2) && (index < 20))	
	{
	[Status setStringValue:"Under weight"];
        [Status setTextColor:NX_COLORYELLOW];
	};


        // Over 29, female, normal
   	if ((agegroup == 3) && (gender == 2) && (index < 24) && (index > 20))
	{
	[Status setStringValue:"Normal"];
        [Status setTextColor:NX_COLORGREEN];
	};

        // Over 29, female, over weight
   	if ((agegroup == 3) && (gender == 2) && (index > 24))
	{
	[Status setStringValue:"Over weight"];
        [Status setTextColor:NX_COLORRED];
	};


    return self;

}



// AWAKEFROMNIB
// This is one of the last methods executed after the nib file is loaded.
// This is the BEST way I know how to initialize an object and jump into
// a method after the nib file was loaded, because you are all the methods
// and variables needed can be used. (Unlike init which is not compeletly
// ready when that message is sent
- awakeFromNib
{
 
	[BMIPanel makeKeyAndOrderFront:NULL];
	[Height selectText:self];

    	return self;
}



@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.