This is MoneyConverter.m in view mode; [Download] [Up]
/* Generated by Project Builder */ #import <appkit/appkit.h> #import "MoneyConverter.h" #define MAXIMUM 6 @implementation MoneyConverter - convert:sender { int index, loop; float entry, value, dollar_equiv; // Array contains the conversion of rates // of other currencies to dollars static float rate[MAXIMUM] = {1.00, 135.0, 0.50, 1.67, 6.00, 14.5}; // Determine which field of the form // was the last to be edited index = [moneyForm selectedIndex]; // Calculate equivalent of foreign currency // at edited field to dollar equivalent entry = [moneyForm floatValueAt:index]; dollar_equiv = entry / rate[index]; for (loop = 0; loop < MAXIMUM; loop++) { // Calculate other currencies // using look-up table value = dollar_equiv * rate[loop]; // display value at appropriate field [moneyForm setFloatValue:value at:loop]; } // leave the last edited field as the // selected text [moneyForm selectTextAt:index]; return self; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.