Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
75
Task/String-matching/FutureBasic/string-matching.basic
Normal file
75
Task/String-matching/FutureBasic/string-matching.basic
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
window 1, @"String matching", (0,0,650,360)
|
||||
|
||||
void local fn DoIt
|
||||
CFStringRef s1, s2
|
||||
CFRange range
|
||||
|
||||
s1 = @"alphabravocharlie"
|
||||
s2 = @"alpha"
|
||||
if ( fn StringHasPrefix( s1, s2 ) )
|
||||
print @"\"";s1;@"\" starts with \"";s2;@"\""
|
||||
else
|
||||
print @"\"";s1;@"\" does not start with \"";s2;@"\""
|
||||
end if
|
||||
|
||||
print
|
||||
|
||||
s2 = @"bravo"
|
||||
if ( fn StringHasPrefix( s1, s2 ) )
|
||||
print @"\"";s1;@"\" starts with \"";s2;@"\""
|
||||
else
|
||||
print @"\"";s1;@"\" does not start with \"";s2;@"\""
|
||||
end if
|
||||
|
||||
print
|
||||
|
||||
range = fn StringRangeOfString( s1, s2 )
|
||||
if ( range.location != NSNotFound )
|
||||
print @"\"";s1;@"\" contains \"";s2;@"\" at location ";(range.location)
|
||||
else
|
||||
print @"\"";s1;@"\" does not contain \"";s2;@"\""
|
||||
end if
|
||||
|
||||
print
|
||||
|
||||
s2 = @"delta"
|
||||
range = fn StringRangeOfString( s1, s2 )
|
||||
if ( range.location != NSNotFound )
|
||||
print @"\"";s1;@"\" contains \"";s2;@"\" at location ";(range.location)
|
||||
else
|
||||
print @"\"";s1;@"\" does not contain \"";s2;@"\""
|
||||
end if
|
||||
|
||||
print
|
||||
|
||||
s2 = @"charlie"
|
||||
if ( fn StringHasSuffix( s1, s2 ) )
|
||||
print @"\"";s1;@"\" ends with \"";s2;@"\""
|
||||
else
|
||||
print @"\"";s1;@"\" does not end with \"";s2;@"\""
|
||||
end if
|
||||
|
||||
print
|
||||
|
||||
s2 = @"alpha"
|
||||
if ( fn StringHasSuffix( s1, s2 ) )
|
||||
print @"\"";s1;@"\" ends with \"";s2;@"\""
|
||||
else
|
||||
print @"\"";s1;@"\" does not end with \"";s2;@"\""
|
||||
end if
|
||||
|
||||
print
|
||||
|
||||
s1 = @"alpha delta charlie delta echo delta futurebasic"
|
||||
s2 = @"delta"
|
||||
range = fn StringRangeOfString( s1, s2 )
|
||||
while ( range.location != NSNotFound )
|
||||
print @"\"";s1;@"\" contains \"";s2;@"\" at location ";(range.location)
|
||||
range.location++
|
||||
range = fn StringRangeOfStringWithOptionsInRange( s1, s2, 0, fn CFRangeMake( range.location, len(s1)-range.location ) )
|
||||
wend
|
||||
end fn
|
||||
|
||||
fn DoIt
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue