RosettaCodeData/Task/Determine-if-a-string-has-all-the-same-characters/FutureBasic/determine-if-a-string-has-all-the-same-characters.basic
2024-11-04 21:53:44 -08:00

30 lines
668 B
Text

defstr byte
void local fn CheckString( s as CFStringRef )
print @"String: \"";s;@"\""
long length = len(s)
if ( length )
unichar prevChr = ucc(s)
for long i = 1 to length - 1
unichar chr = ucc(s,i)
if ( chr != prevChr )
print ,@"character ";ucs(chr);@" at position ";i;@", 0x";hex(chr);@", is the first different character"
return
end if
prevChr = chr
next
end if
print ,@"all characters are the same"
end fn
fn CheckString( @"" )
fn CheckString( @" " )
fn CheckString( @"2" )
fn CheckString( @"333" )
fn CheckString( @".55" )
fn CheckString( @"tttTTT" )
fn CheckString( @"4444 444k" )
HandleEvents