Jay Reeve wrote: > > >Alain has very nicely merged our two functions into one which uses > >the Luhn algorithm to check the validity of account number and return > >the card type from the account number. > > > Wow, there's some complex-looking stuff in there. Must have been translated from c++ or something. Would you believe that this... > > >FOR i = 0 TO L - 1 > >cc( i) = val&( CHR$( ccNum[i + 1] ) ) > >LONG IF( i MOD 2 != 0 AND L MOD 2 != 0) ¬ > >OR( i MOD 2 = 0 AND L MOD 2 = 0 ) > >cc( i ) = cc( i ) < < 1 > >LONG IF cc( i ) > = 10 > >temp = STR$( cc( i ) ) > >cc( i ) = val&( CHR$( temp[2] ) ) ¬ > > + val&( CHR$( temp[3] ) ) > >END IF > >END IF > >NEXT i > > > >FOR i = 0 TO L - 1 > >value + = cc( i ) > >NEXT i > > ...all boils down to this?... > > >FOR i = 1 TO L > >temp = ccNum[i] and 15 > >LONG IF L - i and 1 > >temp += temp > >IF temp > 9 then temp -= 9 > >END IF > >value += temp > >NEXT i > Great! You're almost right, in fact the original version I got was a 275 lines Perl script which didn't even deal with the retrieving of the credit card type. I just hope now you're right with the new algorithm too. -- Cheers Alain ----------------------------------------------------- FB^3 in Europe: http://euro.futurebasic.com/ FB II Pouch: http://www.pixmix.com/FB/outils.html -----------------------------------------------------