ftp.nice.ch/Attic/openStep/tools/calculators/BMI.2.0.w.I.bs.tgz#/BMI.2.0.w.NT.bs/Source/MetricObject.m

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

#import "MetricObject.h"

@implementation MetricObject


- (void)awakeFromNib
// This is one of the last methods executed after the nib file is loaded.
// This is the Best way to initialize an object and jump into
// a method after the nib file was loaded.
{

        [BMIPanel makeKeyAndOrderFront:NULL];
        [WeightTextField selectText:self];
}


- (void)Calc:(id)sender
{

// Decalare Variables

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

// Assign variables

    height = [HeightTextField floatValue];
    weight = [WeightTextField floatValue];

// Calculatate BMI and display BMI

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

        // Display BMI index number
        
        	// Sets TextField as a NSFloatType
        	[[IndexTextField cell] setEntryType:NSFloatType];
                
        	// Format the TextField with two number at the left of the floating point
        	// and two numbers at the right of the floating point.
        	[[IndexTextField cell] setFloatingPointFormat:NO left:2 right:2];
                
        	[IndexTextField setFloatValue:index];// Display result
        	[IndexTextField display];
                
        	// Used for MiscKit Gauge [IndexGauge setDoubleValue:index];// Display result
        	// Used for MiscKit Gauge [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))	
        {
            [StatusTextField setStringValue:@"Normal"];
            [StatusTextField setTextColor:[NSColor greenColor]];
        };

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

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

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



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

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

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

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


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

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



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


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

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

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


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

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

}

@end

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