Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
97
Task/Abbreviations-easy/FutureBasic/abbreviations-easy.basic
Normal file
97
Task/Abbreviations-easy/FutureBasic/abbreviations-easy.basic
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
_window = 1
|
||||
begin enum 1
|
||||
_userStringFld
|
||||
_validateBtn
|
||||
_resultsStringFld
|
||||
end enum
|
||||
|
||||
|
||||
void local fn BuildWindow
|
||||
window _window, @"Abbreviations, easy", (0,0,600,268)
|
||||
WindowSetContentMinSize( _window, fn CGSizeMake( 200, 268 ) )
|
||||
WindowSetContentMaxSize( _window, fn CGSizeMake( 10000, 268 ) )
|
||||
|
||||
textfield _userStringFld,, @"riG rePEAT copies put mo rest types fup. 6 poweRin", (20,152,560,96)
|
||||
TextFieldSetPlaceholderString( _userStringFld, @"Enter commands" )
|
||||
ViewSetAutoresizingMask( _userStringFld, NSViewWidthSizable )
|
||||
|
||||
button _validateBtn,,, @"Validate", (259,117,83,32)
|
||||
ViewSetAutoresizingMask( _validateBtn, NSViewMinXMargin + NSViewMaxXMargin )
|
||||
|
||||
textfield _resultsStringFld,,, (20,20,560,96)
|
||||
TextFieldSetEditable( _resultsStringFld, NO )
|
||||
TextFieldSetSelectable( _resultsStringFld, YES )
|
||||
ViewSetAutoresizingMask( _resultsStringFld, NSViewWidthSizable )
|
||||
end fn
|
||||
|
||||
|
||||
local fn Commands as CFArrayRef
|
||||
CFStringRef words = @"Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy "
|
||||
words = fn StringByAppendingString( words, @"COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find " )
|
||||
words = fn StringByAppendingString( words, @"NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput " )
|
||||
words = fn StringByAppendingString( words, @"Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LPrefix MACRO " )
|
||||
words = fn StringByAppendingString( words, @"MErge MODify MOve MSG Next Overlay PARSE PREServe PURge PUT PUTD Query QUIT " )
|
||||
words = fn StringByAppendingString( words, @"READ RECover REFRESH RENum REPeat Replace CReplace RESet RESTore RGTLEFT " )
|
||||
words = fn StringByAppendingString( words, @"RIght LEft SAVE SET SHift SI SORT SOS STAck STATus TOP TRAnsfer Type Up" )
|
||||
end fn = fn StringComponentsSeparatedByCharactersInSet( words, fn CharacterSetWhitespaceAndNewlineSet )
|
||||
|
||||
|
||||
local fn MinLength( string as CFStringRef ) as long
|
||||
long index, minLength = 0
|
||||
long length = len(string)
|
||||
for index = 0 to length - 1
|
||||
unichar chr = fn StringCharacterAtIndex( string, index )
|
||||
if ( chr >= _"A" and chr <= _"Z" )
|
||||
minLength++
|
||||
else
|
||||
break
|
||||
end if
|
||||
next
|
||||
end fn = minlength
|
||||
|
||||
|
||||
void local fn Validate
|
||||
CFArrayRef commands = fn Commands
|
||||
CFStringRef userString = fn ControlStringValue( _userStringFld )
|
||||
CFArrayRef words = fn StringComponentsSeparatedByCharactersInSet( userString, fn CharacterSetWhitespaceAndNewlineSet )
|
||||
long cmdCount = len(commands)
|
||||
CFMutableStringRef results = fn MutableStringWithCapacity(0)
|
||||
long wordCount = len(words)
|
||||
long i, j
|
||||
for i = 0 to wordCount - 1
|
||||
CFStringRef result = @"*error* "
|
||||
CFStringRef wd = words[i]
|
||||
long wordLength = len(wd)
|
||||
if ( wordLength )
|
||||
for j = 0 to cmdCount - 1
|
||||
CFStringRef cmd = commands[j]
|
||||
if ( fn StringHasPrefix( lcase(cmd), lcase(wd) ) )
|
||||
if ( wordLength >= fn MinLength(cmd) )
|
||||
result = fn StringWithFormat( @"%@ ",ucase(cmd) )
|
||||
break
|
||||
end if
|
||||
end if
|
||||
next
|
||||
MutableStringAppendString( results, result )
|
||||
end if
|
||||
next
|
||||
ControlSetStringValue( _resultsStringFld, results )
|
||||
end fn
|
||||
|
||||
|
||||
void local fn DoDialog( ev as long, tag as long )
|
||||
select ( ev )
|
||||
case _btnClick
|
||||
select ( tag )
|
||||
case _validateBtn : fn Validate
|
||||
end select
|
||||
end select
|
||||
end fn
|
||||
|
||||
|
||||
editmenu 1
|
||||
fn BuildWindow
|
||||
|
||||
on dialog fn DoDialog
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue