Data update
This commit is contained in:
parent
61b93a2cd1
commit
5af6d93694
858 changed files with 20572 additions and 2082 deletions
108
Task/General-FizzBuzz/FutureBasic/general-fizzbuzz.basic
Normal file
108
Task/General-FizzBuzz/FutureBasic/general-fizzbuzz.basic
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
_mfile = 1
|
||||
begin enum
|
||||
_iNewGame
|
||||
_
|
||||
_iClose
|
||||
end enum
|
||||
_mEdit = 2
|
||||
|
||||
_window = 1
|
||||
begin enum 1
|
||||
_maxNumLabel
|
||||
_maxNumFld
|
||||
_f1Label
|
||||
_f1Fld
|
||||
_wd1Label
|
||||
_wd1Fld
|
||||
_f2Label
|
||||
_f2Fld
|
||||
_wd2Label
|
||||
_wd2Fld
|
||||
_f3Label
|
||||
_f3Fld
|
||||
_wd3Label
|
||||
_wd3Fld
|
||||
_playBtn
|
||||
end enum
|
||||
|
||||
void local fn BuildMenu
|
||||
menu _mFile,,, @"File"
|
||||
menu _mFile, _iNewGame,, @"New Game"
|
||||
menu _mFile, _iClose,, @"Close", @"w"
|
||||
MenuItemSetAction( _mFile, _iClose, @"performClose:" )
|
||||
editmenu _mEdit
|
||||
end fn
|
||||
|
||||
void local fn BuildWindow
|
||||
window _window, @"General FizzBuzz", (0,0,362,188), NSWindowStyleMaskTitled
|
||||
|
||||
textlabel _maxNumLabel, @"Maximum number:", (18,150,116,16)
|
||||
textfield _maxNumFld,, @"20", (140,147,202,21)
|
||||
ControlSetFormat( _maxNumFld, @"0123456789", YES, 0, 0 )
|
||||
|
||||
textlabel _f1Label, @"Factor 1:", (18,121,58,16)
|
||||
textfield _f1Fld,, @"3", (80,118,54,21)
|
||||
ControlSetFormat( _f1Fld, @"0123456789", YES, 0, 0 )
|
||||
textlabel _wd1Label, @"Word 1:", (138,121,52,16)
|
||||
textfield _wd1Fld,, @"Fizz", (196,118,146,21)
|
||||
|
||||
textlabel _f2Label, @"Factor 2:", (18,92,58,16)
|
||||
textfield _f2Fld,, @"5", (80,89,54,21)
|
||||
ControlSetFormat( _f2Fld, @"0123456789", YES, 0, 0 )
|
||||
textlabel _wd2Label, @"Word 2:", (138,92,52,16)
|
||||
textfield _wd2Fld,, @"Buzz", (196,89,146,21)
|
||||
|
||||
textlabel _f3Label, @"Factor 3:", (18,63,58,16)
|
||||
textfield _f3Fld,, @"7", (80,60,54,21)
|
||||
ControlSetFormat( _f3Fld, @"0123456789", YES, 0, 0 )
|
||||
textlabel _wd3Label, @"Word 3:", (138,63,52,16)
|
||||
textfield _wd3Fld,, @"Baxx", (196,60,146,21)
|
||||
|
||||
button _playBtn,,, @"Play FizzBuzz", (122,13,118,32)
|
||||
|
||||
WindowMakeFirstResponder( _window, _maxNumFld )
|
||||
end fn
|
||||
|
||||
void local fn PlayFizzBuzz
|
||||
long maxNum = intval(textfield(_maxNumFld))
|
||||
|
||||
long f1 = intval(textfield(_f1Fld))
|
||||
long f2 = intval(textfield(_f2Fld))
|
||||
long f3 = intval(textfield(_f3Fld))
|
||||
|
||||
CFStringRef f1Word = textfield(_wd1Fld)
|
||||
CFStringRef f2Word = textfield(_wd2Fld)
|
||||
CFStringRef f3Word = textfield(_wd3Fld)
|
||||
CFStringRef string = NULL
|
||||
|
||||
NSLogClear
|
||||
|
||||
long i
|
||||
for i = 1 to maxNum
|
||||
string = @""
|
||||
if ( i mod f1 == 0 ) then string = f1Word
|
||||
if ( i mod f2 == 0 ) then string = fn StringByAppendingString( string, f2Word )
|
||||
if ( i mod f3 == 0 ) then string = fn StringByAppendingString( string, f3Word )
|
||||
if ( len(string) == 0 ) then string = fn StringWithFormat( @"%ld", i )
|
||||
NSLog(@"%@",string)
|
||||
next
|
||||
end fn
|
||||
|
||||
|
||||
void local fn DoDialog( ev as long, tag as long )
|
||||
select ( ev )
|
||||
case _btnClick
|
||||
select ( tag )
|
||||
case _playBtn : fn PlayFizzBuzz
|
||||
end select
|
||||
end select
|
||||
end fn
|
||||
|
||||
fn BuildMenu
|
||||
fn BuildWindow
|
||||
|
||||
on dialog fn DoDialog
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue