Basic program window 1, @"Integer Arithmetic", ( 0, 0, 400, 300 ) NSInteger a = 25 NSInteger b = 53 print "addition "a" + "b" = " (a + b) print "subtraction "a" - "b" = " (a - b) print "multiplication "a" * "b" = " (a * b) print "division "a" / "b" = " (a / b) printf @"float division %ld / %ld = %f", a, b, (float)a / (float)b print "modulo "a" % "b" = " (a mod b) print "power "a" ^ "b" = " (a ^ b) HandleEvents Output: addition: 25 + 53 = 78 subtraction: 25 - 53 = -28 multiplication: 25 * 53 = 1325 division: 25 / 53 = 0 float division: 25 / 53 = 0.471698 modulo: 25 mod 53 = 25 power: 25 ^ 53 = 1.232595e+74 Standalone Intel, M1, M2 Macintosh application with user input _window = 1 begin enum 1 _int1Label _int1Field _int2Label _int2Field _calcResults _calcBtn end enum void local fn BuildWindow CGRect r r = fn CGRectMake( 0, 0, 480, 360 ) window _window, @"Integer Arithmetic", r, NSWindowStyleMaskTitled + NSWindowStyleMaskClosable + NSWindowStyleMaskMiniaturizable r = fn CGRectMake( 240, 320, 150, 24 ) textlabel _int1Label, @"Enter first integer:", r, _window ControlSetAlignment( _int1Label, NSTextAlignmentRight ) r = fn CGRectMake( 400, 322, 60, 24 ) textfield _int1Field, YES, @"25", r, _window ControlSetAlignment( _int1Field, NSTextAlignmentCenter ) ControlSetUsesSingleLineMode( _int1Field, YES ) ControlSetFormat( _int1Field, @"0123456789-", YES, 5, NULL ) r = fn CGRectMake( 240, 290, 150, 24 ) textlabel _int2Label, @"Enter second integer:", r, _window ControlSetAlignment( _int2Label, NSTextAlignmentRight ) r = fn CGRectMake( 400, 292, 60, 24 ) textfield _int2Field, YES, @"53", r, _window ControlSetAlignment( _int2Field, NSTextAlignmentCenter ) ControlSetUsesSingleLineMode( _int2Field, YES ) ControlSetFormat( _int2Field, @"0123456789-", YES, 5, NULL ) r = fn CGRectMake( 50, 60, 380, 200 ) textview _calcResults, r,,, _window TextViewSetTextContainerInset( _calcResults, fn CGSizeMake( 10, 20 ) ) TextSetFontWithName( _calcResults, @"Menlo", 13.0 ) TextViewSetEditable( _calcResults, NO ) r = fn CGRectMake( 370, 13, 100, 32 ) button _calcBtn,,, @"Calculate", r end fn local fn PerformCalculations CFStringRef tempStr NSInteger i1 = fn ControlIntegerValue( _int1Field ) NSInteger i2 = fn ControlIntegerValue( _int2Field ) CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 ) // Display inout integers tempStr = fn StringWithFormat( @"Number 1: %ld\nNumber 2: %ld\n\n", i1, i2 ) MutableStringAppendString( mutStr, tempStr ) // Add tempStr = fn StringWithFormat( @"Addition: %ld + %ld = %ld\n", i1, i2, i1 + i2 ) MutableStringAppendString( mutStr, tempStr ) // Subtract tempStr = fn StringWithFormat( @"Subtraction: %ld - %ld = %ld\n", i1, i2, i1 - i2 ) MutableStringAppendString( mutStr, tempStr ) // Multiply tempStr = fn StringWithFormat( @"Multiplication: %ld * %ld = %ld\n", i1, i2, i1 * i2 ) MutableStringAppendString( mutStr, tempStr ) if ( i2 != 0 ) // Divide tempStr = fn StringWithFormat( @"Integer Division: %ld / %ld = %ld\n", i1, i2, i1 / i2 ) MutableStringAppendString( mutStr, tempStr ) // Float Divide tempStr = fn StringWithFormat( @"Float Division: %ld / %ld = %f\n", i1, i2, (float)i1 / (float)i2 ) MutableStringAppendString( mutStr, tempStr ) // mod tempStr = fn StringWithFormat( @"Modulo: %ld mod %ld = %ld remainder\n", i1, i2, i1 mod i2 ) MutableStringAppendString( mutStr, tempStr ) // power tempStr = fn StringWithFormat( @"Power: %ld ^ %ld = %e\n", i1, i2, i1 ^ i2 ) MutableStringAppendString( mutStr, tempStr ) else MutableStringAppendString( mutStr, @"Cannot divide by zero." ) end if TextSetString( _calcResults, mutStr ) end fn void local fn DoDialog( ev as long, tag as long, wnd as long ) '~'1 select ( ev ) case _btnClick select ( tag ) case _calcBtn : fn PerformCalculations end select case _windowWillClose : end end select end fn on dialog fn DoDialog fn BuildWindow HandleEvents Output: Number 1: 25 Number 2: 53 Addition: 25 + 53 = 78 Subtraction: 25 - 53 = -28 Multiplication: 25 * 53 = 1325 Integer Division: 25 / 53 = 0 Float Division: 25 / 53 = 0.471698 Modulo: 25 mod 53 = 25 remainder Power: 25 ^ 53 = 1.232595e+74