This is RegularObject.m in view mode; [Download] [Up]
#import "RegularObject.h"
@implementation RegularObject
- (void)Calc:sender
{
char dummyString[20];
float price;
float tps;
float subtotal;
float tvq;
float total;
price = [Price floatValue];
tps = (price*0.07);
subtotal = (price+tps);
tvq = (subtotal*0.065);
total = (subtotal+tvq);
sprintf(dummyString, "$%.2f", tps); // Convert float to a string
[TPS setStringValue:[NSString stringWithCString:dummyString]];// Display result
[TPS display];
sprintf(dummyString, "$%.2f", subtotal); // Convert float to a string
[SubTotal setStringValue:[NSString stringWithCString:dummyString]];// Display result
[SubTotal display];
sprintf(dummyString, "$%.2f", tvq); // Convert float to a string
[TVQ setStringValue:[NSString stringWithCString:dummyString]];// Display result
[TVQ display];
sprintf(dummyString, "$%.2f", total); // Convert float to a string
[Total setStringValue:[NSString stringWithCString:dummyString]];// Display result
[Total display];
[Price selectText: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
- (void)awakeFromNib
{
[RegularPanel makeKeyAndOrderFront:NULL];
[Price selectText:self];
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.