restrict barcode
restrict barcode
Good day
I want to restrict barcode number to only allow Alphanuremic that starts with
SV19194
SV20967
so that captures cant enter any number
Thanks
I want to restrict barcode number to only allow Alphanuremic that starts with
SV19194
SV20967
so that captures cant enter any number
Thanks
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: restrict barcode
If you just want to make sure that the number starts with SV, you could write something like this:
PROC BARCODE
if BARCODE[1:2] <> "SV" then
errmsg("The barcode must start with SV.");
reenter;
endif;
if BARCODE[1:2] <> "SV" then
errmsg("The barcode must start with SV.");
reenter;
endif;
Re: restrict barcode
Thanks Greg
IT works though i want to be able pass as a missing
i tried that but it can't pass as missing, i want to also allow captures to pass if there's no barcode
IT works though i want to be able pass as a missing
Code: Select all
if BARCODE[1:2] <> "SV" then
errmsg("The barcode must start with SV.");
reenter;
elseif BARCODE = "" then skip to QN136A;
endif;
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: restrict barcode
The problem is that you first do the SV check. You need to switch the checks:
if BARCODE = "" then
skip to QN136A;
elseif BARCODE[1:2] <> "SV" then
errmsg("The barcode must start with SV.");
reenter;
endif;
skip to QN136A;
elseif BARCODE[1:2] <> "SV" then
errmsg("The barcode must start with SV.");
reenter;
endif;
Re: restrict barcode
Why would you want to bother to enter the first two characters if you know for certain that all valid BARCODES will start with SV?
Re: restrict barcode
Dear Greg
let's say for instance i also want to restrict numeric after SV to allow only 5 numeric numbers not less than 5 digits
thanks it worked well though.
Dear Saint
Some ppl don't use a scanner when they collect data so it becomes a problem when they type it in
eg. others capture 9874 or sv432
and that's not what we expect from barcode number.
let's say for instance i also want to restrict numeric after SV to allow only 5 numeric numbers not less than 5 digits
thanks it worked well though.
Dear Saint
Some ppl don't use a scanner when they collect data so it becomes a problem when they type it in
eg. others capture 9874 or sv432
and that's not what we expect from barcode number.
Re: restrict barcode
Mr. Taco I get your point.
If you want to restrict the numeric after SV to be 5 digits, then you full code can look something like this:
If you want to restrict the numeric after SV to be 5 digits, then you full code can look something like this:
Code: Select all
if BARCODE = "" then
skip to QN136A;
elseif BARCODE[1:2] <> "SV" then
errmsg("The barcode must start with SV.");
reenter;
elseif length(strip(BARCODE)) <> 7 then
errmsg("Full barcode must be 7 characters long")
reenter;
else
do i = 3 while i <= 7
if not tonumber(BARCODE[i:1]) in 0:9 then
errmsg("Last five digits of barcode cannot contain a non-numeric character");
reenter;
endif;
enddo;
endif;
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: restrict barcode
Another way of writing what Saint posted is this:
if BARCODE = "" then
skip to QN136A;
elseif BARCODE[1:2] <> "SV" then
errmsg("The barcode must start with SV.");
reenter;
elseif not tonumber(BARCODE[3]) in 10000:99999 then
errmsg("The barcode must be between SV10000 and SV99999.");
reenter;
endif;
skip to QN136A;
elseif BARCODE[1:2] <> "SV" then
errmsg("The barcode must start with SV.");
reenter;
elseif not tonumber(BARCODE[3]) in 10000:99999 then
errmsg("The barcode must be between SV10000 and SV99999.");
reenter;
endif;
Re: restrict barcode
Thanks Saint it worked wonders
Re: restrict barcode
My reservation with Gregory's code will be that it will flag something like SV01000 as an error although from what Mr. Taco says, it could be completely legit: there should be 5 numeric characters after SV.