RosettaCodeData/Task/SEDOLs/FutureBasic/sedols.basic

36 lines
756 B
Plaintext

local fn Checksum( s as CFStringRef ) as CFStringRef
CFStringRef v = @"0123456789-BCD-FGH-JKLMN-PQRST-VWXYZ", w = @"131739"
long i, sum = 0
for i = 0 to len(s) - 1
CFRange r = fn StringRangeOfString( v, mid(s,i,1) )
if ( r.location == NSNotFound ) then return NULL
sum += r.location * intval(mid(w,i,1))
next
end fn = concat( s, @((10 - (sum % 10)) % 10) )
void local fn DoIt
CFArrayRef sedols = @[
@"710889",
@"B0YBKJ",
@"406566",
@"B0YBLH",
@"228276",
@"B0YBKL",
@"557910",
@"B0YBKR",
@"585284",
@"B0YBKT",
@"B00030",
@"ABCDEF"]
CFStringRef sedol
for sedol in sedols
CFStringRef s = fn Checksum( sedol )
if ( s ) then print s : continue
print @"Invalid"
next
end fn
fn DoIt
HandleEvents