mask
Summary
#include <dataman/dataman.h>
-or-
#include <dataman/sort.h>
pt = mask(num,msk);
char *pt, *msk
long int num;
Description
Mask is a routine that does formatting of integers for
output. The argument num is a signed long integer. The
argument msk is a string that takes the general form
"___,__0.__-". Each character represents one column, and
the underscores and the 0 determine the number of digits
to be displayed. The negative (-) sign is optional and
will be left if num is less than zero, otherwise the column will be left blank.
The decimal point
is optional, but if in the mask will always remain in it's defined position. The
zero in the mask indicates where to begin blanking
leading zeros, and the comma is placed in the display for
readability. If the leading zero indicator is found, and
the number doesn't fill the mask the comma will not be
displayed. The output is copied into msk, and the pointer to msk
is returned.
Example
#include <dataman/sort.h>
char msk[] = "___,__0.__-"; /* define a mask */
main(int argc, char *argv[])
{
long int test1;
long int test2;
char disp1[12];
char disp2[12];
test1 = -1234567;
test2 = 12345;
strcpy(disp1,msk);
strcpy(disp2,msk);
show(10,10,mask(test1,disp1),11,10,mask((long)test2,disp2,ENDLIST);
}
The output for this program would begin on line ten and
column ten of the display and look like this:
12,345.67-
123.45
«previous next»