Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
49
Task/CUSIP/FutureBasic/cusip.basic
Normal file
49
Task/CUSIP/FutureBasic/cusip.basic
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
local fn VerifyCUSIP( cusipStr as CFStringRef ) as CFStringRef
|
||||
NSUInteger i, v, sum = 0, count = len(cusipStr)
|
||||
CFStringRef resultStr
|
||||
|
||||
if count != 9 then exit fn = @"Invalid length"
|
||||
|
||||
for i = 0 to 7
|
||||
unichar x = fn StringCharacterAtIndex( cusipStr, i )
|
||||
select x
|
||||
case _"*" : v = 36
|
||||
case _"@" : v = 37
|
||||
case _"#" : v = 38
|
||||
case else
|
||||
if ( x >= _"0" and x <= _"9" )
|
||||
v = x - _"0"
|
||||
else
|
||||
if ( x >= _"A" and x <= _"Z" )
|
||||
v = x - _"A" + 10
|
||||
else
|
||||
exit fn = fn StringWithFormat( @"Invalid character: %c", x )
|
||||
end if
|
||||
end if
|
||||
end select
|
||||
|
||||
if ( i and 1 ) then v = v * 2
|
||||
|
||||
sum += (v / 10) + (v mod 10)
|
||||
next
|
||||
sum = ((10-(sum mod 10)) mod 10)
|
||||
|
||||
if (sum == ( fn StringCharacterAtIndex( cusipStr, 8 ) - _"0" ))
|
||||
resultStr = @"Valid"
|
||||
else
|
||||
resultStr = @"Invalid"
|
||||
end If
|
||||
end fn = resultStr
|
||||
|
||||
NSLog( @"0378331009: %@", fn VerifyCUSIP( @"0378331009" ) ) // Invalid length expected
|
||||
NSLog( @"037833100: %@", fn VerifyCUSIP( @"037833100" ) ) // Valid expected
|
||||
NSLog( @"17275R102: %@", fn VerifyCUSIP( @"17275R102" ) ) // Valid expected
|
||||
NSLog( @"38259P508: %@", fn VerifyCUSIP( @"38259P508" ) ) // Valid expected
|
||||
NSLog( @"594918104: %@", fn VerifyCUSIP( @"594918104" ) ) // Valid expected
|
||||
NSLog( @"68389X106: %@", fn VerifyCUSIP( @"68389X106" ) ) // Invalid expected
|
||||
NSLog( @"68389X105: %@", fn VerifyCUSIP( @"68389X105" ) ) // Valid expected
|
||||
NSLog( @"683&9X105: %@", fn VerifyCUSIP( @"683&9X105" ) ) // Invalid character expected: &
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue