LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

serial number entery

Hi,

 

Unsure what this should come under but I urgently need to implement the following and I do not have the luxury to spend days (in my case) on the trial and error route so I have come to ask for your help, once more!!.

 

I get the date and time and write this information to a text file.

 

Next I perform a number (30) of tests each test writing to the open text file as the test is passed until all tests are preformed at which point the total test time is written to the file and it is closed.

 

If any test fails the test process is stopped.

 

Press of the “Test” command button in my UIR starts the whole process.

 

What I need to add is that when the Test button is pressed the operator is prompted to enter a serial number, which will be written to the file before the rest of the information is written.

 

The serial number will take the format of 2 numbers followed by a letter followed by 6 numbers

                        12H345678

The test should continue once a number has been entered followed by a carriage return.

 

Can you help or point me to the best example so I can code this up with in the next 24 hours!!!??

 

Thanks for the help

Simon

0 Kudos
Message 1 of 3
(3,162 Views)
Hi Simon, try with this code:
 
char buf[16];

while (1) {
 PromptPopup ("Serial number", "Enter DUT serial number (Enter nothing to abort)", buf, 9);
 if (!strlen (buf)) {
  // Code to abort test in progress
  return;
 }
 // Check the S/N enterered is correct
 if (!isdigit (buf[0]) || !isdigit (buf[1])) {
  MessagePopup ("Serial number", "Incorrect number entered: first 2 digits must be numbers.");
 }
 else if (!isalpha(buf[2])) {
  MessagePopup ("Serial number", "Incorrect number entered: 3rd digit must be a character.");
 }
 else if (strspn (buf + 3, "0123456789") < 6) {
  MessagePopup ("Serial number", "Incorrect number entered: last 6 digits must be numbers.");
 }
 else
  break;
}



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(3,154 Views)

Roberto,

So far it looks good, thanks for the help

Thanks

Simon

0 Kudos
Message 3 of 3
(3,150 Views)