BOOL local fn IsGoodISBN( isbn as CFStringRef ) int sum = 0 for int i = 0 to len(isbn) - 1 unichar chr = ucc(isbn,i) - 48 if ( chr > 0 && chr <= 9 ) if ( i % 2 == 0 ) then sum += chr * 3 else sum += chr end if next end fn = sum % 10 == 0 void local fn DoIt CFArrayRef a = @[@"978-0596528126",@"978-0596528120",@"978-1788399081",@"978-1788399083"] for CFStringRef s in a print s, if ( fn IsGoodISBN(s) ) then print @"good" else print @"bad" next end fn fn DoIt HandleEvents