SUBROUTINE CF.LUHN.CHECK(card.no,result) * * LUHN check digit calculation for credit card numbers * * card.no: card number for checking passed in * * result: 0 = Luhn check passed * 1 = invalid string * 2 = check fails * * ======================================================================== * * Conditions of use: * This source code remains the property and copyright of Gulraj Rijhwani * and Courtfields Limited. Specific licence is granted to copy and use * this program source, in accordance with the terms and conditions laid * out following. For the purposes of these terms and conditions the term * "developer" is defined to be the individual or company employing the * author incorporating use of this source. Any use of this source code is * deemed to be full and unreserved acceptance of these stated terms. * * 1) All instances of this source code must carry all attached * annotations and comments including, but not limited to, these * these conditions of use in their entirety. * 2) The developer may not alter the program source in any way, without * first obtaining the express written consent of duly authorised * company officers of Courtfields Limited, or its successors. * 3) This source code may not be included in whole or in part in any * proprietary program suite except as a separately compiled module * in wholly unmodified form. Any installed object code must be * accompanied by the original source code at all times. * 4) In the event of any breach of these terms and conditions the * developer shall be liable for an annual usage charge of 200 pounds * sterling for every end user terminal or session using or having * access to use the resulting executable code. * 5) Gulraj Rijhwani and Courtfields Limited make no warranties for * the fitness of this source code, and may not be held liable * for any failure to fulfil the expectations or requirements of * the developer. * * ======================================================================== * result = (card.no='') OR (OCONV(card.no,'MCN')#card.no); * Invalid characters IF result THEN RETURN * chk.tot = 0 no.of.digits = LEN(card.no) mpx = 1 FOR dig.ptr=no.of.digits TO 1 STEP -1 dig.res = mpx * card.no[dig.ptr,1] chk.tot += dig.res - 9 * (dig.res>9) mpx = REM(mpx,2) + 1 NEXT dig.ptr * result = 2 * (REM(chk.tot,10)#0); * Invalid card no * RETURN