1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
Function CheckNID_General(&NATIONAL_ID, &NID_TYPE, &COUNTRY, &NIDFormat); Local string &Alpha, &Alpha_xz, &Numeric, &TestChar, &MaskChar; Local number &iNID, &LengthNID; Local boolean &IsFormatError; &Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; &Alpha_xz = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "; &Numeric = "1234567890"; &AlphaNum_SGP = &Alpha | &Numeric | "-"; &IsFormatError = False; If All(&NATIONAL_ID) Then If All(&NIDFormat) Then &LengthNID = Len(&NIDFormat); If &COUNTRY = "MYS" Then &Alpha = &Alpha | " "; If &NID_TYPE <> "NEWIC" Then &LengthNID = Len(&NATIONAL_ID); End-If; End-If; If Len(&NATIONAL_ID) > &LengthNID Then &IsFormatError = True; End-If; &K = 0; For &J = 1 To &LengthNID &ChkChar = Substring(&NIDFormat, &J, 1); If &ChkChar = "X" Or &MaskChar = "Z" Then &K = &K + 1; End-If; End-For; If &K <> Len(&NATIONAL_ID) Or &K <> &LengthNID Then &iNID = 1; While &iNID <= &LengthNID And Not &IsFormatError &TestChar = Substring(&NATIONAL_ID, &iNID, 1); &MaskChar = Substring(&NIDFormat, &iNID, 1); Evaluate &MaskChar When = "X" When = "Z" If Find(&TestChar, &Numeric) <> 0 Or Find(&TestChar, &Alpha_xz) <> 0 Then &IsFormatError = False; Else &IsFormatError = True; End-If; Break; When = "9" If Find(&TestChar, &Numeric) = 0 Then &IsFormatError = True; End-If; Break; When = "D" If Find(&TestChar, &AlphaNum_SGP) = 0 Then &IsFormatError = True; End-If; Break; When = "A" If Find(&TestChar, &Alpha) = 0 Then &IsFormatError = True; End-If; Break; When-Other If &TestChar <> &MaskChar Then &IsFormatError = True; End-If; Break; End-Evaluate; &iNID = &iNID + 1; End-While; End-If; If &IsFormatError Then If &ValidateServiceCall Then throw create HCR_PERSON_EXCEPTIONS:PersonExceptions:ValidateNIDExceptions_v1_0:NIDFormatException( Null, &NID_TYPE, &COUNTRY, &NIDFormat); Else Error (MsgGet(1000, 490, "Message Not Found", &NID_TYPE, &COUNTRY, &NIDFormat)); End-If; End-If; End-If; End-If; End-Function;
|