How to add an ENTER or CRLF to this Barcode

J

Joyrider

First let me say that I am not a C programmer. I have a small piece of
code used in a hand held data collector. Its purpose is to pad zeros
to the front of a scanned barcode so its length is 14 char. What I
want is for an ENTER to be suffixed so the user does not have to press
the Enter button after the scan and padding. If anyone can help me I
would be very appreciative.

char buf[16];

void _PadZero_3()
{
unsigned n;
int pos, row;

n = strlen(_CountUpc_F01);
if (n <14){
pos = _get_cursor();
row = ((pos >> 8) & 0xff) - 1;
sprintf(buf, "%014s", _CountUpc_F01);
strcpy(_CountUpc_F01, buf);
_set_cursor(row, 0);
printf("%s\n", _CountUpc_F01);
}
}
 
S

Spiros Bousbouras

Joyrider said:
First let me say that I am not a C programmer. I have a small piece of
code used in a hand held data collector. Its purpose is to pad zeros
to the front of a scanned barcode so its length is 14 char. What I
want is for an ENTER to be suffixed...

You want ENTER (by which I assume you mean \n)
to be suffixed to what ?
...so the user does not have to press
the Enter button after the scan and padding. If anyone can help me I
would be very appreciative.

char buf[16];

void _PadZero_3()
{
unsigned n;
int pos, row;

n = strlen(_CountUpc_F01);
if (n <14){
pos = _get_cursor();
row = ((pos >> 8) & 0xff) - 1;
sprintf(buf, "%014s", _CountUpc_F01);

I'm not sure this is legal ; the 0 flag doesn't work
with s.
 
J

Joyrider

Send an Enter after _CountUPC_F01. I thought it could be part of this
variable, but again, I am not a programmer.

Spiros said:
Joyrider said:
First let me say that I am not a C programmer. I have a small piece of
code used in a hand held data collector. Its purpose is to pad zeros
to the front of a scanned barcode so its length is 14 char. What I
want is for an ENTER to be suffixed...

You want ENTER (by which I assume you mean \n)
to be suffixed to what ?
...so the user does not have to press
the Enter button after the scan and padding. If anyone can help me I
would be very appreciative.

char buf[16];

void _PadZero_3()
{
unsigned n;
int pos, row;

n = strlen(_CountUpc_F01);
if (n <14){
pos = _get_cursor();
row = ((pos >> 8) & 0xff) - 1;
sprintf(buf, "%014s", _CountUpc_F01);

I'm not sure this is legal ; the 0 flag doesn't work
with s.

This is working code.
 
S

Spiros Bousbouras

Joyrider said:
Send an Enter after _CountUPC_F01. I thought it could be part of this
variable, but again, I am not a programmer.

Enter is a key not a character. If by Enter you
mean a newline sequence then the statement
printf("%s\n", _CountUpc_F01) already does
that. What makes you think that it doesn't ?
Spiros said:
Joyrider said:
char buf[16];

void _PadZero_3()
{
unsigned n;
int pos, row;

n = strlen(_CountUpc_F01);
if (n <14){
pos = _get_cursor();
row = ((pos >> 8) & 0xff) - 1;
sprintf(buf, "%014s", _CountUpc_F01);

I'm not sure this is legal ; the 0 flag doesn't work
with s.

This is working code.

Undefined behaviour is consistent with "working" code.
 
W

Walter Roberson

I have a small piece of
code used in a hand held data collector. Its purpose is to pad zeros
to the front of a scanned barcode so its length is 14 char. What I
want is for an ENTER to be suffixed so the user does not have to press
the Enter button after the scan and padding.

Do I understand correctly that there is some kind of forms processing
going on, and after you fill in that field of the form, you want to
trigger the forms input routine for that field, as if the user had
typed in the value and triggered the input routine themselves?

If that is the case, then there is no way in Standard C to do that.
Standard C can create output, but arranging for that output to trigger
input is beyond the specifications of C itself.

There might be ways available through the facilities provided by
your forms package, but you would have to check a newsgroup or
source more familiar with that package to find out.

It is not the ENTER or return itself that concerns you, right? It is
the action that ENTER or return would trigger that you want to
trigger, right?

Some forms packages have no way of doing this. Others rely on hacks
like telling the output device to program the "answerback" sequence
and then sending a "who are you" request to get the device to emit
that string as if the user had entered it. Others rely upon
"synthetic key presses" being generated. Lots of different ways,
most of them ugly and a pain to use.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top