This tutorial shows how to call a simple DLL function, which performs a quick check on a credit card number. Click here to download the flowchart/zipfile, which accompanies this tutorial topic.
i. What is a LUHN check?
Most international credit card numbers (including Visa and Mastercard) conform to a LUHN checksum algorithm.
It is possible to calculate the last digit of a card number, by examining all the preceeding digits.
This will not indicate if the card is stolen, but it can be used to check if the user has made a mistake when entering a card number.
1. The DLL function
The zipfile which accompanies this topic contains the C source code for a DLL. This DLL contains a single function, the prototype is shown below:
/*
This function performs LUHN checksum validation for the specified card number.
It returns non-zero if the checksum is valid, zero if invalid.
*/
__declspec(dllexport)
int CheckLuhn(char* pstrCardNumber);
2. Begin a new flowchart
Run the SQLphone Designer program, to begin a new flowchart.
Remember to select Options from the Prompt menu, and setup the prompt directory.
You can leave all the standard prompt options unticked.
Note: This tutorial topic does not need a database.
Click here to recall the "New flowchart checklist" topic.
3. Add memories
Press the <New Memory> button on the toolbar, to create the following two memories:
| Memories | |
| Name | Description |
|---|---|
| Card | Stores the credit card number entered by a user |
| OK | Stores the DLL return code: zero = failure, non-zero = success |
4. Add prompts
Press the <New Prompt> button on the toolbar, to create the following three voice prompts:
| Prompts (wave files) | |
| Name | Description |
|---|---|
| EnterCard | "Please enter your credit card number" |
| CardGood | "Card number is good" |
| CardBad | "Card number is invalid" |
When you create new prompts, you can press the <Sound recorder> button to record using your own voice, or you can press the <Generate...> button to record using a synthesized voice.
5. Add a box to get a credit card number
Add a new Digits Box to the flowchart. Name the box Get Card, then click the Digits tab. Setup as shown in figure 1.
![]() |
Figure 1 |
6. Add a box to check the card number
Add a new DLL Box to the flowchart. Name the box Check Card, then click the DLL tab. Setup as shown in figure 2.
![]() |
Figure 2 |
![]() |
Figure 3 |
7. Add a box to report valid card
Add a new Play Box to the flowchart.
Name the box Card OK, then click the Play tab. Setup as shown in figure 4.
![]() |
Figure 4 |
8. Add a box to report invalid card
Add a new Play Box to the flowchart.
Name the box Card Fail, then click the Play tab. Setup as shown in figure 5.
![]() |
Figure 5 |
9. Allow the user to make a mistake
If the user enters an invalid card number, allow them to have another go.
This is achieved by setting a retry counter. Double click the Get Card box,
then click the Conditions tab. Setup the retry counter, see figure 6.
![]() |
Figure 6 |
10. Join the boxes
Join up the flowchart box conditions, and setup the Get Card box as the flowchart starting point. See figure 7.
![]() |
Figure 7 |
11. Test the flowchart
Press F5 to test the flowchart.
Click here to download the flowchart, which accompanies this tutorial topic.