T168_111\appl\Parser\Zpl2:第13个文件

Zpl2FuncFmt.c  、、、、、、、、、、、、、、、、、、、、、、、

/******************************************************************************
 *                                                                            *
 *                         M O D U L E   D E F I N E                          *
 *                                                                            *
 ******************************************************************************/

#define ZPL2FUNCFMT_C

/******************************************************************************
 *                                                                            *
 *        C O M P I L E R   D E F I N E D   I N C L U D E   F I L E S         *
 *                                                                            *
 ******************************************************************************/

#include <stdio.h>
#include <ctype.h>
#include <string.h>

/******************************************************************************
 *                                                                            *
 *            U S E R   D E F I N E D   I N C L U D E   F I L E S             *
 *                                                                            *
 ******************************************************************************/

#include "Common.h"
#include "XCore.h"
#include "XFunction.h"
#include "..\Parser.h"
#include "..\ParserUtil.h"
#include "Zpl2Util.h"
#include "Zpl2Image.h"
#include "Zpl2Format.h"
#include "Zpl2Field.h"
#include "Zpl2FieldData.h"
#include "Zpl2Object.h"
#include "Zpl2Control.h"
#include "Zpl2Report.h"
#include "Zpl2Func.h"

/******************************************************************************
 *                                                                            *
 *                         L O C A L   D E F I N E S                          *
 *                                                                            *
 ******************************************************************************/

#if defined(ZPL2)

/******************************************************************************
 *                                                                            *
 *                        L O C A L   T Y P E D E F S                         *
 *                                                                            *
 ******************************************************************************/

/******************************************************************************
 *                                                                            *
 *             L O C A L   F U N C T I O N   P R O T O T Y P E S              *
 *                                                                            *
 ******************************************************************************/

/******************************************************************************
 *                                                                            *
 *    L O C A L   I N I T I A L I Z E D   D A T A   D E F I N I T I O N S     *
 *                                                                            *
 ******************************************************************************/

_CmdEntry EntryFormatB[] = 
{
    {"0",            FormatB0},
    {"1",            FormatB1},
    {"2",            FormatB2},
    {"3",            FormatB3},
    {"4",            FormatB4},
    {"5",            FormatB5},
    {"7",            FormatB7},
    {"8",            FormatB8},
    {"9",            FormatB9},
    {"A",            FormatBA},
    {"B",            FormatBB},
    {"C",            FormatBC},
    {"D",            FormatBD},
    {"E",            FormatBE},
    {"F",            FormatBF},
    {"I",            FormatBI},
    {"J",            FormatBJ},
    {"K",            FormatBK},
    {"L",            FormatBL},
    {"M",            FormatBM},
    {"O",            FormatB0},
    {"P",            FormatBP},
    {"Q",            FormatBQ},
    {"R",            FormatBR},
    {"S",            FormatBS},
    {"T",            FormatBT},
    {"U",            FormatBU},
    {"X",            FormatBX},
    {"Y",            FormatBY},
    {"Z",            FormatBZ},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatC[] = 
{
    {"C",            FormatCC},
    {"D",            FormatCD},
    {"F",            FormatCF},
    {"I",            FormatCI},
    {"M",            FormatCM},
    {"O",            FormatCO},
    {"T",            FormatCT},
    {"V",            FormatCV},
    {"W",            FormatCW},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatD[] = 
{
    {"F",            FormatDF},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatE[] = 
{
    {"F",            FormatEF},
    {"G",            FormatEG},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatF[] = 
{
    {"A",            FormatFA},
    {"B",            FormatFB},
    {"C",            FormatFC},
    {"D",            FormatFD},
    {"H",            FormatFH},
    {"M",            FormatFM},
    {"N",            FormatFN},
    {"O",            FormatFO},
    {"P",            FormatFP},
    {"R",            FormatFR},
    {"S",            FormatFS},
    {"T",            FormatFT},
    {"V",            FormatFV},
    {"W",            FormatFW},
    {"X",            FormatFX},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatG[] = 
{
    {"B",            FormatGB},
    {"C",            FormatGC},
    {"D",            FormatGD},
    {"E",            FormatGE},
    {"F",            FormatGF},
    {"S",            FormatGS},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatH[] = 
{
    {"F",            FormatHF},
    {"G",            FormatHG},
    {"H",            FormatHH},
    {"W",            FormatHW},
    {"Y",            FormatHY},
    {"Z",            FormatHZ},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatI[] = 
{
    {"D",            FormatID},
    {"L",            FormatIL},
    {"M",            FormatIM},
    {"S",            FormatIS},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatJ[] = 
{
    {"B",            FormatJB},
    {"I",            FormatJI},
    {"J",            FormatJJ},
    {"M",            FormatJM},
    {"S",            FormatJS},
    {"T",            FormatJT},
    {"U",            FormatJU},
    {"W",            FormatJW},
    {"Z",            FormatJZ},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatK[] = 
{
    {"D",            FormatKD},
    {"L",            FormatKL},
    {"N",            FormatKN},
    {"P",            FormatKP},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatL[] = 
{
    {"H",            FormatLH},
    {"L",            FormatLL},
    {"R",            FormatLR},
    {"S",            FormatLS},
    {"T",            FormatLT},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatM[] = 
{
    {"C",            FormatMC},
    {"D",            FormatMD},
    {"F",            FormatMF},
    {"L",            FormatML},
    {"M",            FormatMM},
    {"N",            FormatMN},
    {"P",            FormatMP},
    {"T",            FormatMT},
    {"U",            FormatMU},
    {"W",            FormatMW},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatN[] = 
{
    {"I",            FormatNI},
    {"S",            FormatNS},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatP[] = 
{
    {"F",            FormatPF},
    {"H",            FormatPH},
    {"M",            FormatPM},
    {"O",            FormatPO},
    {"P",            FormatPP},
    {"Q",            FormatPQ},
    {"R",            FormatPR},
    {"W",            FormatPW},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatS[] = 
{
    {"C",            FormatSC},
    {"E",            FormatSE},
    {"F",            FormatSF},
    {"L",            FormatSL},
    {"N",            FormatSN},
    {"O",            FormatSO},
    {"P",            FormatSP},
    {"Q",            FormatSQ},
    {"R",            FormatSR},
    {"S",            FormatSS},
    {"T",            FormatST},
    {"X",            FormatSX},
    {"Z",            FormatSZ},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatT[] = 
{
    {"O",            FormatTO},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatW[] = 
{
    {"D",            FormatWD},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatX[] = 
{
    {"A",            FormatXA},
    {"B",            FormatXB},
    {"F",            FormatXF},
    {"G",            FormatXG},
    {"Z",            FormatXZ},
    {(CHAR *)_NULL,    _NULL}
};

_CmdEntry EntryFormatZ[] = 
{
    {"Z",            FormatZZ},
    {(CHAR *)_NULL,    _NULL}
};

/******************************************************************************
 *                                                                            *
 *    L O C A L   U N I T I A L I Z E D   D A T A   D E F I N I T I O N S     *
 *                                                                            *
 ******************************************************************************/

/******************************************************************************
 *
 * ZPL II Commands ^A ^A@
 *        ^A  - Scalable/Bitmapped Font
 *        ^A@ - Use Font Name to Call Font
 *
 * Description:
 *        The ^A command is a scalable/bitmapped font that uses built-in or
 *        TrueType fonts. ^A designates the font for the current ^FD statement or
 *        field. The font specified by ^A is used only once for that ^FD entry. If
 *        a value for ^A is not specifed again, the default ^CF font is used for
 *        the next ^FD entry.
 *        The ^A@ command uses the complete name of a font, rather than the
 *        character designation used in ^A. Once a value for ^A@ id defined, it
 *        represents that font until a new font name is specified by ^A@.
 *
 * Format:
 *        ^Afo,h,w
 *        ^A@o,h,w,d:0.x
 *
 * Parameters:
 *      f = font name
 *      o = font orientation
 *      h = character height(in dots)
 *      w = width(in dots)
 *        d = drive location of font
 *        o = font name
 *        x = extension
 *
 ******************************************************************************/
INT FormatA(VOID)
{
    INT state;
    CHAR FontID;
    _FieldFont Font;

    FontID = FieldDef.Font.ID;            // Default Value: A

    // Default Value: the last accepted ^FW value or the ^FW default
    Font.Orientation = FieldDef.Orientation;

    // Bitmapped Default Value: the standard matrix height for a specifed font
    Font.Height = 0;

    // Bitmapped Default Value: the standard matrix width for a specifed font
    Font.Width = 0;

    // Device Default Value: R
    // Name Default Value: if an invalid or no name is entered, the default set by ^CF is used. 
    //                     If no font has been specified in ^CF, font A is used.
    Font.File = FieldDef.FontFile;

    while (1)
    {
        // Accepted Values: A through Z, 0 to 9, @
        if (state = ParamFont(&FontID))
            break;
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Font.Orientation, "NRIB", TRUE))
            break;
        // Bitmapped Accepted Values: multipes of height form 1 to 10 times
        //                            the standard height, in increments of 1
        if (state = ParamUnit(&Font.Height, 0, 32000, TRUE))
            break;
        // Bitmapped Accepted Values: multipes of width form 1 to 10 times
        //                            the standard width, in increments of 1
        if (state = ParamUnit(&Font.Width, 0, 32000, TRUE))
            break;

        // ^A@ - Use Font Name to Call Font
        if (FontID == '@')
        {
            // Accepted Values: R:, E:, B: and A:
            if (state = ParamDevice(&Font.File.Device))
                break;
            // Accepted Values: any name up to 8 characters, extension fixed value: .FNT
            if (state = ParamName(Font.File.Name, 1, "FNT"))
                break;
        }
        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (FontID == '@')
            FieldDef.FontFile = Font.File;
        else
            Font.File = *FontIdentifier(FontID);

        Field.FontSet = TRUE;
        if (Field.DrawType != DRAW_BARCODE)
            Field.DrawType = DRAW_FONT;

        Field.Draw.Font = Font;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatB(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatB))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^B0
 *        Aztec Bar Code 
 *
 * Description:
 *
 * Format:
 *        ^B0a,b,c,d,e,f,g
 *
 * Parameters:
 *      a = orientation
 *      b = magnification factor
 *      c = extended channel interpretation code indicator
 *      d = error control and symbol size/type indicator
 *      e = menu symbol indicator
 *      f = number of symbols for structured append
 *      g = optional ID field for structured append
 *
 ******************************************************************************/
INT FormatB0(VOID)
{
    INT state;
    _FieldBarcode Barcode;     
    _FieldData FieldID;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_AZTEC;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Columns = 0;                        // Default Value: not specified
    Barcode.ParamChar1 = 'N';                    // Default Value: N
    Barcode.ParamNum1 = 0;                        // Default Value: 0
    Barcode.ParamChar2 = 'N';                    // Default Value: N
    Barcode.Rows = 1;                            // Default Value: 1

    // Default Value: no ID
    FieldID.Length = 0;
    strcpy(FieldID.Content, "");

    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 10
        if (state = ParamUnit(&Barcode.Columns, 0, 10, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.ParamChar1, "YN", TRUE))
            break;
        // Accepted Values: 0 to 300
        if (state = ParamNumber(&Barcode.ParamNum1, PARAM_NUMBER_SHORT, 0, 300))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.ParamChar2, "YN", TRUE))
            break;
        // Accepted Values: 1 through 26
        if (state = ParamNumber(&Barcode.Rows, PARAM_NUMBER_SHORT, 1, 26))
            break;
        // Accepted Values: The ID field is a text string with 24-character maximum
        if (state = ParamData(&FieldID, &Field.HexIndicator, Field.ClockIndicator, TRUE))
            break;
        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        // Magnification is not specified
        if (Barcode.Columns == 0)
        {
            // Default Value: 1 on 150 dpi printers
            //                2 on 200 dpi printers
            //                3 on 300 dpi printers
            //                6 on 600 dpi printers
            Barcode.Columns = (SHORT)(TPH_DPI / 100);
        }

        strncpy(Barcode.FieldID, FieldID.Content, sizeof(Barcode.FieldID));
        Barcode.FieldID[sizeof(Barcode.FieldID) - 1] = '\0';

        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^B1
 *        Code 11 Bar Code
 *
 * Description:
 *
 * Format:
 *        ^B1o,e,h,f,g
 *
 * Parameters:
 *      o = orientation
 *      e = check digit
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatB1(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_CODE11;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Check = 'N';                        // Default Value: N
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: Y(yes) = 1 digit, N(no) = 2 digit
        if (state = ParamChar(&Barcode.Check, "YN", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^B2
 *        Interleaved 2 of 5 Bar Code
 *
 * Description:
 *
 * Format:
 *        ^B2o,h,f,g,e
 *
 * Parameters:
 *      o = orientation
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *      e = calculate and print Mod 10 check digit
 *
 ******************************************************************************/
INT FormatB2(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_INTERLEAVE25;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    Barcode.Check = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Check, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^B3
 *        Code 39 Bar Code
 *
 * Description:
 *
 * Format:
 *        ^B3o,e,h,f,g
 *
 * Parameters:
 *      o = orientation
 *      e = Mod-43 check digit
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatB3(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_CODE39;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Check = 'N';                        // Default Value: N
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Check, "YN", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^B4
 *        Code 49 Bar Code
 *
 * Description:
 *
 * Format:
 *        ^B4o,h,f,m
 *
 * Parameters:
 *      o = orientation
 *      h = height multiplier of individual rows
 *      f = print interpretation line
 *      m = starting mode
 *
 ******************************************************************************/
INT FormatB4(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_CODE49;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = 0;                            // Default Value: not specified
    Barcode.Interp = 'N';                        // Default Value: N
    Barcode.Mode = 'A';                            // Default Value: A
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to height of label
        if (state = ParamNumber(&Barcode.Height, PARAM_NUMBER_SHORT, 1, 32000))
            break;
        // Accepted Values: N = no line printed, A = above, B = below
        if (state = ParamChar(&Barcode.Interp, "YAB", TRUE))
            break;
        // Accepted Values: 0 to 5, and A
        if (state = ParamChar(&Barcode.Mode, "012345A", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^B5
 *        Planet Code bar code
 *
 * Description:
 *
 * Format:
 *        ^B5o,h,f,g
 *
 * Parameters:
 *      o = orientation code
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatB5(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_PLANET_CODE;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'N';                        // Default Value: N
    Barcode.Above = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 9999
        if (state = ParamUnit(&Barcode.Height, 1, 9999, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^B7
 *        PDF417 Bar Code
 *
 * Description:
 *
 * Format:
 *        ^B7o,h,s,c,r,t
 *
 * Parameters:
 *      o = orientation code
 *      h = bar code height for individual rows(in dots)
 *      s = security level
 *      c = number of data columns to encode
 *      r = number of rows to encode
 *      t = truncate right row indicators and stop pattern
 *
 ******************************************************************************/
INT FormatB7(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_PDF417;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.ParamNum1 = 0;                        // Default Value: value set by ^BY
    Barcode.ParamNum2 = 0;                        // Default Value: 0(error detection only)
    Barcode.Columns = 0;                        // Default Value: not specified
    Barcode.Rows = 0;                            // Default Value: not specified
    Barcode.ParamChar1 = 'N';                    // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to height of label
        if (state = ParamNumber(&Barcode.ParamNum1, PARAM_NUMBER_SHORT, 1, 32000))
            break;
        // Accepted Values: 1 to 8(error detection and correction)
        if (state = ParamNumber(&Barcode.ParamNum2, PARAM_NUMBER_SHORT, 1, 8))
            break;
        // Accepted Values: 1 to 30
        if (state = ParamNumber(&Barcode.Columns, PARAM_NUMBER_SHORT, 1, 30))
            break;
        // Accepted Values: 3 to 90
        if (state = ParamNumber(&Barcode.Rows, PARAM_NUMBER_SHORT, 3, 90))
            break;
        // Accepted Values: Y(perform truncation) or N(no truncation)
        if (state = ParamChar(&Barcode.ParamChar1, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
//        if (Barcode.Columns == 0)                // Columns is not specified
//            Barcode.Columns = Barcode.Rows * 2;    // Default Value: 1:2(row-to-column)
//        if (Barcode.Rows == 0)                    // Rows is not specified
//            Barcode.Rows = Barcode.Columns / 2;    // Default Value: 1:2(row-to-column)

        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^B8
 *        EAN-8 Bar Code
 *
 * Description:
 *
 * Format:
 *        ^B8o,h,f,g
 *
 * Parameters:
 *      o = orientation code
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatB8(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_EAN8;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^B9
 *        UPC-E Bar Code
 *
 * Description:
 *
 * Format:
 *        ^B9o,h,f,g,e
 *
 * Parameters:
 *      o = orientation
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *      e = print check digit
 *
 ******************************************************************************/
INT FormatB9(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_UPCE;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    Barcode.Check = 'Y';                        // Default Value: Y
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Check, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BA
 *        Code 93 Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BAo,h,f,g,e
 *
 * Parameters:
 *      o = orientation
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *      e = print check digit
 *
 ******************************************************************************/
INT FormatBA(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_CODE93;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    Barcode.Check = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Check, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BB
 *        CODABLOCK Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BBo,h,s,c,r,m
 *
 * Parameters:
 *      o = orientation code
 *      h = bar code height for individual rows(in dots)
 *      s = security level
 *      c = number of characters per row(data cloumns)
 *      r = number of rows to encode
 *      m = mode
 *
 ******************************************************************************/
INT FormatBB(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_CODABLOCK;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Height = FieldDef.Barcode.Height;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.ParamNum1 = 8;                        // Default Value: 8
    Barcode.ParamChar1 = 'Y';                    // Default Value: Y
    Barcode.Columns = 0;                        // Default Value: not specified
    Barcode.Rows = 0;                            // Default Value: not specified
    Barcode.Mode = 'F';                            // Default Value: F
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 2 to 32000
        if (state = ParamUnit(&Barcode.ParamNum1, 2, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.ParamChar1, "YN", TRUE))
            break;
        // Accepted Values: 2 to 62 (to 255?) characters 
        if (state = ParamUnit(&Barcode.Columns, 1, 32000, TRUE))
            break;
        // Accepted Values: CODABLOCK A: 1 to 22, CODABLOCK E and F: 2 to 4, (to 255?)
        if (state = ParamUnit(&Barcode.Rows, 1, 32000, TRUE))
            break;
        // Accepted Values: A, E, F
        if (state = ParamChar(&Barcode.Mode, "AEF", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (CheckChar(Barcode.Mode, "EF"))
        {
            // Accepted Values: CODABLOCK E and F: 2 to 4
            if (Barcode.Rows < 2 || Barcode.Rows > 4)
                Barcode.Rows = 0;    // not specifed
        }
        // Columns and Rows are not specified
        if (Barcode.Columns == 0 && Barcode.Rows == 0)
        {
            // a single now is produced
            Barcode.Rows = 1;
        }
        // Columns is not specified
        else if (Barcode.Columns == 0)
        {
            // ...
        }
        // Rows is not specified
        else if (Barcode.Rows == 0)
        {
            // ...
        }

        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BC
 *        Code 128 Bar Code(Subsets A, B, and C)
 *
 * Description:
 *
 * Format:
 *        ^BCo,h,f,g,e,m
 *
 * Parameters:
 *      o = orientation
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *      e = UCC check digit
 *      m = mode
 *
 ******************************************************************************/
INT FormatBC(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_CODE128;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    Barcode.Check = 'N';                        // Default Value: N
    Barcode.Mode = 'N';                            // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Check, "YN", TRUE))
            break;
        // Accepted Values: N = no selected, U = UCC Case, A = Automatic, D = UCC/EAN Mode
        if (state = ParamChar(&Barcode.Mode, "NUAD", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (Barcode.Mode == 'U' || Barcode.Mode == 'D')
            Barcode.Type = BARCODE_EAN128;
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BD
 *        UPS MaxiCode Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BDm,n,t
 *
 * Parameters:
 *      m = mode
 *      n = symbol number
 *      t = total number of symbols
 *
 ******************************************************************************/
INT FormatBD(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    // The ^BY command has no effect on the UPS MaxiCode bar code.

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_UPS_MAXICODE;
    Barcode.Mode = 2;                            // Default Value: 2
    Barcode.ParamNum1 = 1;                        // Default Value: 1
    Barcode.ParamNum2 = 1;                        // Default Value: 1
    while (1)
    {
        // Accepted Values: 2 to 6
        if (state = ParamNumber(&Barcode.Mode, PARAM_NUMBER_CHAR, 2, 6))
            break;
        // Accepted Values: 1 to 8 can be added in a structured document
        if (state = ParamNumber(&Barcode.ParamNum1, PARAM_NUMBER_SHORT, 1, 8))
            break;
        // Accepted Values: 1 to 8, representing the total number of symbols in this sequence
        if (state = ParamNumber(&Barcode.ParamNum2, PARAM_NUMBER_SHORT, 1, 8))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BE
 *        EAN-13 Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BEo,h,f,g
 *
 * Parameters:
 *      o = orientation
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatBE(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_EAN13;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BF
 *        Micro PDF417 Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BFo,h,m
 *
 * Parameters:
 *      o = orientation code
 *      h = bar code height for individual rows(in dots)
 *      m = mode
 *
 ******************************************************************************/
INT FormatBF(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_MICRO_PDF417;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Mode = 0;                            // Default Value: 0
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 9999
        if (state = ParamNumber(&Barcode.Height, PARAM_NUMBER_SHORT, 1, 9999))
            break;
        // Accepted Values: 0 to 33
        if (state = ParamNumber(&Barcode.Mode, PARAM_NUMBER_CHAR, 0, 33))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BI
 *        Industrial 2 of 5 Bar Codes
 *
 * Description:
 *
 * Format:
 *        ^BIo,h,f,g
 *
 * Parameters:
 *      o = orientation
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatBI(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_INDUSTRIAL25;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BJ
 *        Standard 2 of 5 Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BJo,h,f,g
 *
 * Parameters:
 *      o = orientation
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatBJ(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_STANDARD25;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BK
 *        ANSI Codabar Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BKo,e,h,f,g,k,l
 *
 * Parameters:
 *      o = orientation
 *      e = check digit
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *        k = designates a start character
 *        l = designates stop character
 *
 ******************************************************************************/
INT FormatBK(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_ANSI_CODABAR;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Check = 'N';                        // Fixed Value: N
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    Barcode.ParamChar1 = 'A';                    // Default Value: A
    Barcode.ParamChar2 = 'A';                    // Default Value: A
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Fixed Value: N
        if (state = ParamChar(&Barcode.Check, "N", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;
        // Accepted Values: A, B, C, D        // * would be treated as C in codabar.c
        if (state = ParamChar(&Barcode.ParamChar1, "ABCD*", TRUE))
            break;
        // Accepted Values: A, B, C, D        // * would be treated as C in codabar.c
        if (state = ParamChar(&Barcode.ParamChar2, "ABCD*", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BL
 *        LOGMARS Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BLo,h,g
 *
 * Parameters:
 *      o = orientation
 *      h = bar code height(in dots)
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatBL(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_LOGMARS;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Above = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BM
 *        MSI Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BMo,e,h,f,g,e2
 *
 * Parameters:
 *      o = orientation
 *      e = check digit selection
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *        e2 = designates start character
 *
 ******************************************************************************/
INT FormatBM(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_MSI;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Check = 'B';                        // Default Value: B
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    Barcode.ParamChar1 = 'N';                    // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values:    A = no check digits
        //                    B = 1 Mod 10
        //                    C = 2 Mod 10
        //                    D = 1 Mod 10 and 1 Mod 11
        if (state = ParamChar(&Barcode.Check, "ABCD", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.ParamChar1, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BP
 *        Plessey Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BPo,e,h,f,g
 *
 * Parameters:
 *      o = orientation
 *      e = print check digit
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatBP(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_PLESSEY;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Check = 'N';                        // Default Value: N
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Check, "YN", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BQ
 *        QR Code Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BQa,b,c
 *
 * Parameters:
 *      a = field position
 *      b = model
 *      c = magnification factor
 *
 ******************************************************************************/
INT FormatBQ(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_QR_CODE;
    Barcode.Orientation = 'N';                    // Fixed Value: normal
    Barcode.Mode = 2;                            // Default Value: 2
    Barcode.ParamNum1 = 0;                        // Default Value: not specified

    while (1)
    {
        // Fixed Value: normal
        if (state = ParamChar(&Barcode.Orientation, "N", TRUE))
            break;
        // Accepted Values: 1(original) and 2(enhanced-recommended)
        if (state = ParamNumber(&Barcode.Mode, PARAM_NUMBER_CHAR, 1, 2))
            break;
        // Accepted Values: 1 to 10
        if (state = ParamUnit(&Barcode.ParamNum1, 0, 10, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        // Magnification is not specified
        if (Barcode.ParamNum1 == 0)
        {
            // Default Value: 1 on 150 dpi printers
            //                2 on 200 dpi printers
            //                3 on 300 dpi printers
            //                6 on 600 dpi printers
            Barcode.ParamNum1 = (SHORT)(TPH_DPI / 100);
        }

        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BR
 *        RSS Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BRa,b,c,d,e,f
 *
 * Parameters:
 *      a = orientation
 *      b = symbology type in the RSS-14 family
 *      c = magnification factor
 *      d = separator height
 *      e = bar code height
 *      f = the segment width(RSS expanded only)
 *
 ******************************************************************************/
INT FormatBR(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_RSS;
    Barcode.Orientation = 'R';                    // Default Value: R
    Barcode.Mode = 1;                            // Default Value: 1 (symbology type:RSS14)
    Barcode.Columns = 0;                        // Default Value: not specified
    Barcode.Rows = 1;                            // Default Value: 1 (separator height)
    Barcode.ParamNum1 = 0;                        // Default Value: not specified
    Barcode.ParamNum2 = 22;                        // Default Value: 22 (the segment width, even number only, range:2~22)
    while (1)
    {
        // orientation -- Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // symbology type -- Accepted Values: 1 to 12
        if (state = ParamNumber(&Barcode.Mode, PARAM_NUMBER_CHAR, 1, 12))
            break;
        // magnification factor(module width) -- Accepted Values: 1 to 10
        if (state = ParamUnit(&Barcode.Columns, 0, 10, TRUE))
            break;
        // separator height -- Accepted Values: 1 or 2
        if (state = ParamNumber(&Barcode.Rows, PARAM_NUMBER_SHORT, 1, 2))
            break;
        // barcode height -- Accepted Values: 1 to 32000 (Only UCC/EAN and CC-A/B/C.)
        if (state = ParamUnit(&Barcode.ParamNum1, 0, 32000, TRUE))
            break;
        // the segment width -- Accepted Values: 2 to 22 (RSS expand only)
        if (state = ParamNumber(&Barcode.ParamNum2, PARAM_NUMBER_SHORT, 2, 22))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        // Magnification is not specified
        if (Barcode.Columns == 0)
        {
            // Default Value: 24 dot = 6, 12 dot is 3, 8 dot and lower is 2
            //                12 dot = 6, > 8 dot is 3, 8 dot and less is 2
            Barcode.Columns = (SHORT)(TPH_DPI / 100);
        }
        if (Barcode.ParamNum1 == 0)
            Barcode.ParamNum1 = 25;

        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BS
 *        UPC/EAN Extensions
 *
 * Description:
 *
 * Format:
 *        ^BSo,h,f,g
 *
 * Parameters:
 *      o = orientation code
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatBS(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_UPC_EAN;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'Y';                        // Default Value: Y
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 9999
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BT
 *        TLC39 bar code
 *
 * Description:
 *
 * Format:
 *        ^BTo,w1,r1,h1,w2,h2
 *
 * Parameters:
 *      o = orientation
 *        w1 = width of the code 39 bar code
 *        r1 = wide to narrow bar width ratio the code 39 bar code
 *        h1 = height of the code 39 bar code
 *        w2 = narrow bar width of the Micro-PDF417 bar code
 *        h2 = row height of the Micro-PDF417 bar code
 *
 ******************************************************************************/
INT FormatBT(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_TLC39;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Width = (TPH_DPI + 100) / 150;        // Default Value(200- and 300 dpi printer): 2
    Barcode.Ratio = (FLOAT)2.0;                    // Default Value: 2.0
    Barcode.Height = (SHORT)(TPH_DPI / 5);        // Default Value(300 dpi printer): 60
                                                //              (200 dpi printer): 40
    Barcode.ParamNum1 = (TPH_DPI + 100) / 150;    // Default Value(200- and 300 dpi printers): 2
    Barcode.ParamNum2 = Barcode.ParamNum1 * 2;    // Default Value(200- and 300 dpi printers): 4
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 10
        if (state = ParamUnit(&Barcode.Width, 1, 10, TRUE))
            break;
        // Accepted Values: 2.0 to 3.0
        if (state = ParamNumber(&Barcode.Ratio, PARAM_NUMBER_FLOAT, 2.0, 3.0))
            break;
        // Accepted Values: 1 to 9999
        if (state = ParamUnit(&Barcode.Height, 1, 9999, TRUE))
            break;
        // Accepted Values: 1 to 10
        if (state = ParamUnit(&Barcode.ParamNum1, 1, 10, TRUE))
            break;
        // Accepted Values: 1 to 255
        if (state = ParamUnit(&Barcode.ParamNum2, 1, 255, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BU
 *        UPC-A Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BUo,h,f,g,e
 *
 * Parameters:
 *      o = orientation
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *      e = print check digit
 *
 ******************************************************************************/
INT FormatBU(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_UPCA;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'Y';                        // Default Value: Y
    Barcode.Above = 'N';                        // Default Value: N
    Barcode.Check = 'Y';                        // Default Value: Y
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 9999
        if (state = ParamUnit(&Barcode.Height, 1, 9999, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Check, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BX
 *        Data Matrix Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BXo,h,s,c,r,f,g
 *
 * Parameters:
 *      o = orientation
 *      h = dimensional height of individual symbol elements
 *      s = quality level
 *      c = columns to encode
 *      r = rows to encode
 *      f = format ID(0 to 6)-not used with quality set at 200
 *        g = escape sequence control character
 *
 ******************************************************************************/
INT FormatBX(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_DATA_MATRIX;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = 1;                            // Default Value: 1
    Barcode.ParamNum1 = 0;                        // Default Value: 0
    Barcode.Columns = 0;                        // Default Value: not specified
    Barcode.Rows = 0;                            // Default Value: not specified
    Barcode.Mode = 6;                            // Default Value: 6
    Barcode.ParamChar1 = '_';                    // Default Value: _(underscore)
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to width of label
        if (state = ParamNumber(&Barcode.Height, PARAM_NUMBER_SHORT, 1, 32000))
            break;
        // Accepted Values: 0, 50, 80, 100, 140, 200
        if (state = ParamNumber(&Barcode.ParamNum1, PARAM_NUMBER_SHORT, 0, 200))
            break;
        // Accepted Values: 9 to 49
        if (state = ParamNumber(&Barcode.Columns, PARAM_NUMBER_SHORT, 9, 49))
            break;
        // Accepted Values: 9 to 49
        if (state = ParamNumber(&Barcode.Rows, PARAM_NUMBER_SHORT, 9, 49))
            break;
        // Accepted Values: 1 to 6
        if (state = ParamNumber(&Barcode.Mode, PARAM_NUMBER_CHAR, 1, 6))
            break;
        // Accepted Values: any character
        if (state = ParamChar(&Barcode.ParamChar1, "", FALSE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (Barcode.Columns == 0)    // Columns is not specified
        {
            // ...
        }
        if (Barcode.Rows == 0)        // Rows is not specified
        {
            // ...
        }

        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BY
 *        Bar Code Field Default
 *
 * Description:
 *
 * Format:
 *        ^BYw,r,h
 *
 * Parameters:
 *      w = module width(in dots)
 *      r = wide bar to narrow bar width ratio
 *      h = bar code height(in dots)
 *
 ******************************************************************************/
INT FormatBY(VOID)
{
    INT state;
    SHORT Width  = 0;    // not specified
    FLOAT Ratio  = 0;    // not specified
    SHORT Height = 0;    // not specified

    while (1)
    {
        // Accepted Values: 1 to 10, apparently Zebra take more
        if (state = ParamUnit(&Width, 1, 32000, TRUE))
            break;
        // Accepted Values: 2.0 to 3.0, in 0.1 increments
        if (state = ParamNumber(&Ratio, PARAM_NUMBER_FLOAT, 2.0, 3.0))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Height, 1, 32000, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        FieldDef.Barcode.Width  = Width  ? Width  : FieldDef.Barcode.Width;
        FieldDef.Barcode.Ratio  = Ratio  ? Ratio  : FieldDef.Barcode.Ratio;
        FieldDef.Barcode.Height = Height ? Height : FieldDef.Barcode.Height;
        if (Field.DrawType == DRAW_BARCODE)
        {
            Field.Draw.Barcode.Width  = Width  ? Width  : Field.Draw.Barcode.Width;
            Field.Draw.Barcode.Ratio  = Ratio  ? Ratio  : Field.Draw.Barcode.Ratio;
            Field.Draw.Barcode.Height = Height ? Height : Field.Draw.Barcode.Height;
        }
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^BZ
 *        POSTNET Bar Code
 *
 * Description:
 *
 * Format:
 *        ^BZo,h,f,g
 *
 * Parameters:
 *      o = orientation code
 *      h = bar code height(in dots)
 *      f = print interpretation line
 *        g = print interpretation line above code
 *
 ******************************************************************************/
INT FormatBZ(VOID)
{
    INT state;
    _FieldBarcode Barcode;

    memset(&Barcode, 0, sizeof(_FieldBarcode));
    Barcode.Type = BARCODE_POSTNET;
    Barcode.Width = FieldDef.Barcode.Width;
    Barcode.Ratio = FieldDef.Barcode.Ratio;
    Barcode.Orientation = FieldDef.Orientation;    // Default Value: current ^FW value
    Barcode.Height = FieldDef.Barcode.Height;    // Default Value: value set by ^BY
    Barcode.Interp = 'N';                        // Default Value: N
    Barcode.Above = 'N';                        // Default Value: N
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Barcode.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Barcode.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Interp, "YN", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Barcode.Above, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_BARCODE;
        Field.Draw.Barcode = Barcode;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatC(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatC))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^CC ~CC
 *        Change Carets
 *
 * Description:
 *        The ^CC and ~CC commands is used to change the format command prefix.
 *        The default prefix is the caret(^).
 *
 * Format:
 *        ^CCx or ~CCx
 *
 * Parameters:
 *      x = caret character change
 *
 ******************************************************************************/
INT FormatCC(VOID)
{
    // Accepted Values: any ASCII character
    // Default Value: a parameter is required. If a parameter is not entered,
    //                the next character received is the new prefix character.
    CaretChar = ZebraNextByte(NEXT_ANY);
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^CD ~CD
 *        Change Delimiter
 *
 * Description:
 *        The ^CD and ~CD commands is used to change the delimiter character. This
 *        character is used to separate parameter values associated with several
 *        ZPL II commands. The default delimiter is a comma(,).
 *
 * Format:
 *        ^CDa or ~CDa
 *
 * Parameters:
 *      a = delimiter character change
 *
 ******************************************************************************/
INT FormatCD(VOID)
{
    // Accepted Values: any ASCII character
    // Default Value: a parameter is required. If a parameter is not entered,
    //                the next character received is the new prefix character.
    DelimiterChar = ZebraNextByte(NEXT_ANY);
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^CF
 *        Change Alphanumeric Default Font
 *
 * Description:
 *        The ^CF command sets the default font used in your printer. You can use
 *        the ^CF command to simplify your programs.
 *
 * Format:
 *        ^CFf,h,w
 *
 * Parameters:
 *      f = specified default font
 *      h = individual character height(in dots)
 *      w = individual character width(in dots)
 *
 ******************************************************************************/
INT FormatCF(VOID)
{
    INT state;
    _DefaultFont DefFont;
    DefFont.ID = FieldDef.Font.ID;
    DefFont.Height = 0;    // not specified
    DefFont.Width = 0;    // not specified

    while (1)
    {
        // Accepted Values: A through Z and 0 to 9
        if (state = ParamChar(&DefFont.ID, "", TRUE))
            break;
        // Accepted Values: 0 to 32000
        if (state = ParamUnit(&DefFont.Height, 0, 32000, TRUE))
            break;
        // Accepted Values: 0 to 32000
        if (state = ParamUnit(&DefFont.Width, 0, 32000, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        // Accepted Values: A through Z, 0 to 9
        if (!isupper(DefFont.ID) && !isdigit(DefFont.ID))
            DefFont.ID = FieldDef.Font.ID;            // reload

        FieldDef.Font = DefFont;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^CI
 *        Change International Font
 *
 * Description:
 *
 * Format:
 *        ^CIa,s1,d1,s2,d2,...
 *
 * Parameters:
 *      a = desired character set
 *      s = source(character position to be remapped)
 *      d = destination(new position for the character referred to in source)
 *
 ******************************************************************************/
INT FormatCI(VOID)
{
    INT state;
    BYTE Remap[37][256];
    BYTE Set;
    SHORT Source;
    SHORT Dest;

    Set = CharacterSet;
    memcpy(Remap, ZplRemapChar, sizeof(Remap));
    while (1)
    {
        // Accepted Values: 0 to 36
        if (state = ParamNumber(&Set, PARAM_NUMBER_CHAR, 0, 36))
            break;

        while (1)
        {
            Source = Dest = -1;
            if (state = ParamNumber(&Source, PARAM_NUMBER_SHORT, 0, 255))
                break;
            state = ParamNumber(&Dest, PARAM_NUMBER_SHORT, 0, 255);

            // Accepted Values: decimals 0 to 255
            if (Source >= 0 && Source <= 255 && Dest >= 0 && Dest <= 255)
                Remap[Set][Dest] = Source;

            if (state != PARAM_NULL)
                break;
        }

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        CharacterSet = Set;
        memcpy(ZplRemapChar, Remap, sizeof(ZplRemapChar));
        SetCodePageCross(LANG_ZPL, &CharacterSet, ZplRemapChar[Set]);
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^CM
 *        Change Memory Letter Designation
 *
 * Description:
 *
 * Format:
 *        ^CMa,b,c,d
 *
 * Parameters:
 *      a = memory alias letter designation
 *      b = memory alias letter designation
 *      c = memory alias letter designation
 *      d = memory alias letter designation
 *
 ******************************************************************************/
INT FormatCM(VOID)
{
    INT state;
    _MemoryAlias MemAlias;

    MemAlias.B = 'B';                            // Default Value: B
    MemAlias.E = 'E';                            // Default Value: E
    MemAlias.R = 'R';                            // Default Value: R
    MemAlias.A = 'A';                            // Default Value: A
    while (1)
    {
        // Accepted Values: B:, E:, R:, A:, and NONE
        if (state = ParamChar(&MemAlias.B, "BERA", TRUE))
            break;
        // Accepted Values: B:, E:, R:, A:, and NONE
        if (state = ParamChar(&MemAlias.E, "BERA", TRUE))
            break;
        // Accepted Values: B:, E:, R:, A:, and NONE
        if (state = ParamChar(&MemAlias.R, "BERA", TRUE))
            break;
        // Accepted Values: B:, E:, R:, A:, and NONE
        if (state = ParamChar(&MemAlias.A, "BERA", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        // Any duplicate parameters entered reset the letter designations back to the default
        if (MemAlias.B == MemAlias.E || MemAlias.R == MemAlias.A ||
            MemAlias.B == MemAlias.R || MemAlias.E == MemAlias.A ||
            MemAlias.B == MemAlias.A || MemAlias.E == MemAlias.R)
        {
            MemAlias.B = 'B';
            MemAlias.E = 'E';
            MemAlias.R = 'R';
            MemAlias.A = 'A';
        }
        MemoryAlias = MemAlias;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^CO
 *        Cache On
 *
 * Description:
 *
 * Format:
 *        ^COa,b,c
 *
 * Parameters:
 *      a = cache on
 *      b = amount of additional memory to be added to cache(in K)
 *      c = cache type
 *
 ******************************************************************************/
INT FormatCO(VOID)
{
    INT state;
    CHAR CacheOn;
    SHORT AdditionCache;
    SHORT CacheType;

    CacheOn = 'Y';                                // Default Value: Y
    AdditionCache = 40;                            // Default Value: 40
    CacheType = 0;                                // Default Value: 0
    while (1)
    {
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&CacheOn, "YN", TRUE))
            break;
        // Accepted Values: any size up to total memory available
        if (state = ParamNumber(&AdditionCache, PARAM_NUMBER_SHORT, 0, 32000))
            break;
        // Accepted Values: 0 = cache buffer(normal fonts)
        //                  1 = internal buffer(recommended for Asian fonts)
        if (state = ParamNumber(&CacheType, PARAM_NUMBER_SHORT, 0, 1))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^CT ~CT
 *        Change Tilde
 *
 * Description:
 *        The ^CT and ~CT commands is used to change the control command prefix.
 *        The default prefix is the tilde(~).
 *
 * Format:
 *        ^CTa or ~CTa
 *
 * Parameters:
 *      a = change control command character
 *
 ******************************************************************************/
INT FormatCT(VOID)
{
    // Accepted Values: any ASCII character
    // Default Value: a parameter is required. If a parameter is not entered,
    //                the next character received is the new control character.
    TildeChar = ZebraNextByte(NEXT_ANY);
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^CV
 *        Code Validation
 *
 * Description:
 *
 * Format:
 *        ^CVa
 *
 * Parameters:
 *      a = code validation
 *
 ******************************************************************************/
INT FormatCV(VOID)
{
    INT state;
    CHAR Validation;

    Validation = 'N';                            // Default Value: N

    while (1)
    {
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Validation, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        CodeValidation = Validation;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^CW
 *        Font Identifier
 *
 * Description:
 *
 * Format:
 *        ^CWa,d:o.x
 *
 * Parameters:
 *      a = letter of existing font to be substituted, or new font to be added
 *      d = device to store font in(optional)
 *      o = name of the downlaoded font to be substituted for the built-in,
 *            or as an additional font
 *      x = extension
 *
 ******************************************************************************/
INT FormatCW(VOID)
{
    INT state;
    CHAR Font = _NULL;        // Default Value: a one-character entry id required
    _ObjFile File;

    File.Device = MemoryAlias.R;        // Default Value: R
    strcpy(File.Name, "UNKNOWN.FNT");    // Default Value: UNKNOWN.FNT
    while (1)
    {
        // Accepted Values: A through Z, 0 to 9
        if (state = ParamChar(&Font, "", TRUE))
            break;
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&File.Device))
            break;
        // Accepted Values: any name up to 8 characters, extension fixed value: .FNT
        if (state = ParamName(File.Name, 1, "FNT"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        SHORT Width, Height;

        if (isupper(Font) || isdigit(Font))
        {
            if (GetFontSize(File.Name, LANG_ZPL, &Width, &Height) ||
                SearchScalableFont(File.Name))
                *FontIdentifier(Font) = File;
        }
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatD(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatD))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^DF
 *        Download Format
 *
 * Description:
 *
 * Format:
 *        ^DFd:o.x
 *
 * Parameters:
 *      d = device to store image
 *      o = image name
 *      x = extension
 *
 ******************************************************************************/
INT FormatDF(VOID)
{
    INT state;
    _ObjFile File;

    File.Device = MemoryAlias.R;        // Default Value: R
    strcpy(File.Name, "UNKNOWN.ZPL");    // Default Value: UNKNOWN.ZPL
    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&File.Device))
            break;
        // Accepted Values: any name up to 8 characters, extension fixed value: .ZPL
        if (state = ParamName(File.Name, 1, "ZPL"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        DownloadFormat(&File);
        EndFormat();
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatE(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatE))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^EF
 *        Erase Stored Formats
 *
 * Description:
 *        The ^EF command erase all stored formats.
 *
 * Format:
 *        ^EF
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatEF(VOID)
{
    ObjectDelete('R', "*.ZPL");
    ObjectDelete('B', "*.ZPL");
    ObjectDelete('E', "*.ZPL");
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^EG
 *        Erase Download Graphics
 *
 * Description:
 *
 * Format:
 *        ^EG
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatEG(VOID)
{
    ObjectDelete('R', "*.GRF");
    ObjectDelete('B', "*.GRF");
    ObjectDelete('E', "*.GRF");
    return _SUCCESS;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatF(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatF))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FA
 *        Field Allocate
 *
 * Description:
 *
 * Format:
 *        ^FAn
 *
 * Parameters:
 *        n = Number of character spaces to be saved
 *
 ******************************************************************************/
INT FormatFA(VOID)
{
    INT state;
    SHORT Allocate = 0;    // Default Value: Instruction is ignored if no value is specified.

    while (1)
    {
        // Accepted Values: 1 to 3072
        if (state = ParamNumber(&Allocate, PARAM_NUMBER_SHORT, 1, 3072))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (Allocate)
            Field.Allocate = Allocate;

        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FB
 *        Field Block
 *
 * Description:
 *
 * Format:
 *        ^FBa,b,c,d,e
 *
 * Parameters:
 *      a = width of text block line(in dots)
 *      b = maximum number of lines in text block
 *      c = add or delete space between lines(in dots)
 *      d = text justification
 *      e = hanging indent(in dots) of the second and remaining lines
 *
 ******************************************************************************/
INT FormatFB(VOID)
{
    INT state;

    // Default Value: Width: 0, Line: 1, Space: 0, Justification: L, HangingIndent: 0
    _FieldBlock Block = {TRUE, 0, 1, 0, 'L', 0};

    while (1)
    {
        // Accepted Values: 0 to the width of the label(or 9999)
        if (state = ParamNumber(&Block.Width, PARAM_NUMBER_SHORT, 0, 9999))
            break;
        // Accepted Values: 1 to 9999
        if (state = ParamNumber(&Block.Line, PARAM_NUMBER_SHORT, 1, 9999))
            break;
        // Accepted Values: -9999 to 9999
        if (state = ParamNumber(&Block.Space, PARAM_NUMBER_SHORT, -9999, 9999))
            break;
        // Accepted Values: L(left) C(center) R(rigth) J(justified)
        if (state = ParamChar(&Block.Justification, "LCRJ", TRUE))
            break;
        // Accepted Values: 0 to 9999
        if (state = ParamNumber(&Block.HangingIndent, PARAM_NUMBER_SHORT, 0, 9999))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
            Field.Typeset = TRUE;
        Field.Block = Block;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FC
 *        Field Clock(for Real-Time Clock)
 *
 * Description:
 *
 * Format:
 *        ^FCa,b,c
 *
 * Parameters:
 *      a = primary clock indicator character
 *      b = secondary clock indicator character
 *      c = terticator character
 *
 ******************************************************************************/
INT FormatFC(VOID)
{
    INT state;
    CHAR Indicator[3] = {'%', 0, 0};            // Default Value: %

    while (1)
    {
        // Accepted Values: any ASCII character
        if (state = ParamChar(&Indicator[0], "", FALSE))
            break;
        // Accepted Values: any ASCII character
        if (state = ParamChar(&Indicator[1], "", FALSE))
            break;
        // Accepted Values: any ASCII character
        if (state = ParamChar(&Indicator[2], "", FALSE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        memcpy(Field.ClockIndicator, Indicator, sizeof(Field.ClockIndicator));
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FD
 *        Field Data
 *
 * Description:
 *
 * Format:
 *        ^FDa
 *
 * Parameters:
 *      a = data to be printed
 *
 ******************************************************************************/
INT FormatFD(VOID)
{
    INT state;
    _FieldData Data;

    // Default Value: none - a string of characters must be entered
    Data.Length = 0;
    strcpy(Data.Content, "");

    while (1)
    {
        // Accepted Values: any ASCII string up to 3072 characters
        if (state = ParamData(&Data, &Field.HexIndicator, Field.ClockIndicator, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DataType = FIELD_DATA;
        FieldData = Data;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FH
 *        Field Hexadecimal Indicator
 *
 * Description:
 *
 * Format:
 *        ^FHa
 *
 * Parameters:
 *      a = hexadecimal indicator
 *
 ******************************************************************************/
INT FormatFH(VOID)
{
    INT state;
    CHAR Indicator = '_';                        // Default Value: _(underscore)

    while (1)
    {
        // Accepted Values: any character except current format and control prefix
        //                  (^ and ~ by default)
        if (state = ParamChar(&Indicator, "", FALSE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.HexIndicator = Indicator;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FM
 *        Multiple Field Origin Locations
 *
 * Description:
 *
 * Format:
 *        ^FMx1,y1,x2,y2,...
 *
 * Parameters:
 *      x1 = x-axis location of first symbol(in dots)
 *        y1 = y-axis location of first symbol(in dots)
 *      x2 = x-axis location of second symbol(in dots)
 *        y2 = y-axis location of second symbol(in dots)
 *        ... = continuation of X,Y pairs
 *
 ******************************************************************************/
INT FormatFM(VOID)
{
    INT state;
    INT i;
    _Axis Multi[60];                // Default Value: a value must be specified

    for (i = 0; i < 60; i++)
    {
        // Accepted Values: 0 to 32000, e = exclude this bar code from printing
        if (state = ParamUnit(&Multi[i].X, 0, 32000, TRUE))
            break;
        // Accepted Values: 0 to 32000, e = exclude this bar code from printing
        if (state = ParamUnit(&Multi[i].Y, 0, 32000, TRUE))
            break;
    }
    if (i == 60)
        state = ParamEnd();

    if (state == PARAM_SUCCESS && FormatStart)
    {
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FN
 *        Field Number
 *
 * Description:
 *
 * Format:
 *        ^FN#
 *
 * Parameters:
 *      # = number to be assigned to the field
 *
 ******************************************************************************/
INT FormatFN(VOID)
{
    INT state;
    SHORT Number = 0;                            // Default Value: 0

    while (1)
    {
        // Accepted Values: 0 to 9999
        if (state = ParamNumber(&Number, PARAM_NUMBER_SHORT, 0, 9999))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.Number = Number;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FO
 *        Field Origin
 *
 * Description:
 *
 * Format:
 *        ^FOx,y
 *
 * Parameters:
 *      x = x-axis location(in dots)
 *        y = y-axis location(in dots)
 *
 ******************************************************************************/
 INT AAAAAAAAA = 0;
INT FormatFO(VOID)
{
    INT state;
    _Axis Origin = {0, 0};                        // Default Values: 0

    while (1)
    {
        // Accepted Values: 0 to 32000
        if (state = ParamUnit(&Origin.X, 0, 32000, TRUE))
            break;
        // Accepted Values: 0 to 32000
        if (state = ParamUnit(&Origin.Y, 0, 32000, TRUE))
            break;

        state = ParamEnd();
        break;
    }
        if(Origin.X==92&&Origin.Y ==10)
        {
            AAAAAAAAA = 1;
          debug_printf("-");
        }
        else
        {
            AAAAAAAAA = 0;
        }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.Typeset = FALSE;
        Field.Origin = Origin;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FP
 *        Field Parameter
 *
 * Description:
 *
 * Format:
 *        ^FPd,g
 *
 * Parameters:
 *      d = direction
 *        g = additional inter-character gap(in dots)
 *
 ******************************************************************************/
INT FormatFP(VOID)
{
    INT state;

    // Direction Default Values: 'H'
    // Character Gap Default Values: 0 if no value is entered
    _FieldParameter Parameter = {'H', 0};

    while (1)
    {
        // Accepted Values: H, V, R
        if (state = ParamChar(&Parameter.Direction, "HVR", TRUE))
            break;
        // Accepted Values: 0 to 9999
        if (state = ParamNumber(&Parameter.CharacterGap, PARAM_NUMBER_SHORT, 0, 9999))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.Parameter = Parameter;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FR
 *        Field Reverse Print
 *
 * Description:
 *
 * Format:
 *        ^FR
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatFR(VOID)
{
    if (FormatStart)
        Field.Reverse = TRUE;
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^FS
 *        Field Separator
 *
 * Description:
 *
 * Format:
 *        ^FS
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatFS(VOID)
{
    if (FormatStart)
        FieldSeparator();
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^FT
 *        Field Typeset
 *
 * Description:
 *
 * Format:
 *        ^FTx,y
 *
 * Parameters:
 *      x = x-axis location(in dots)
 *        y = y-axis location(in dots)
 *
 ******************************************************************************/
INT FormatFT(VOID)
{
    INT state;

    // Default Values: position after last formarred text field
    _Axis Origin = TypesetOrigin;

    while (1)
    {
        // Accepted Values: 0 to 32000
        if (state = ParamUnit(&Origin.X, 0, 32000, TRUE))
            break;
        // Accepted Values: 0 to 32000
        if (state = ParamUnit(&Origin.Y, 0, 32000, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.Typeset = TRUE;
        Field.Origin = Origin;
        TypesetOrigin = Origin;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FV
 *        Field Variable
 *
 * Description:
 *
 * Format:
 *        ^FVa
 *
 * Parameters:
 *      a = variable field data to be printed
 *
 ******************************************************************************/
INT FormatFV(VOID)
{
    INT state;
    _FieldData Data;

    // Default Value: if no data is entered, the command is ignored
    Data.Length = 0;
    strcpy(Data.Content, "");

    while (1)
    {
        // Accepted Values: 0 to 3072 character string
        if (state = ParamData(&Data, &Field.HexIndicator, Field.ClockIndicator, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DataType = FIELD_VARIABLE;
        FieldData = Data;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FW
 *        Field Orientation
 *
 * Description:
 *
 * Format:
 *        ^FWr
 *
 * Parameters:
 *      r = rotate field
 *
 ******************************************************************************/
INT FormatFW(VOID)
{
    INT state;
    CHAR Orientation = FieldDef.Orientation;

    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Orientation, "NRIB", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        FieldDef.Orientation = Orientation;
        Field.Draw.Font.Orientation = Orientation;
        Field.Draw.Barcode.Orientation = Orientation;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^FX
 *        Comment
 *
 * Description:
 *
 * Format:
 *        ^FXc
 *
 * Parameters:
 *      c = non printing comment
 *
 ******************************************************************************/
INT FormatFX(VOID)
{
    ParamEnd();
    return _SUCCESS;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatG(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatG))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^GB
 *        Graphic Box
 *
 * Description:
 *
 * Format:
 *        ^GBw,h,t,c,r
 *
 * Parameters:
 *      w = box width(in dots)
 *      h = box height(in dots)
 *      t = border thickness(in dots)
 *      c = line color
 *      r = degree of corner-rounding
 *
 ******************************************************************************/
INT FormatGB(VOID)
{
    INT state;
    _FieldGraphic Graphic;
    SHORT RoundingIndex;
    SHORT RoundingRadius;
    SHORT ShorterSide;

    memset(&Graphic, 0, sizeof(_FieldGraphic));
    Graphic.Width = 1;            // Default Value: value used for thickness(t) or 1
    Graphic.Height = 1;            // Default Value: value used for thickness(t) or 1
    Graphic.Thickness = 1;        // Default Value: 1
    Graphic.Color = 'B';        // Default Value: B
    RoundingIndex = 0;            // Default Value: 0
    while (1)
    {
        // Accepted Values: value of t to 32000
        if (state = ParamUnit(&Graphic.Width, 1, 32000, TRUE))
            break;
        // Accepted Values: value of t to 32000
        if (state = ParamUnit(&Graphic.Height, 1, 32000, TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Graphic.Thickness, 1, 32000, TRUE))
            break;
        // Accepted Values: B(black) or W(white)
        if (state = ParamChar(&Graphic.Color, "BW", TRUE))
            break;
        // Accepted Values: 0(no rounding) to 8(heaviest rounding)
        if (state = ParamNumber(&RoundingIndex, PARAM_NUMBER_SHORT, 0, 8))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (Graphic.Width < Graphic.Thickness)
            Graphic.Width = Graphic.Thickness;
        if (Graphic.Height < Graphic.Thickness)
            Graphic.Height = Graphic.Thickness;

        ShorterSide = Graphic.Width < Graphic.Height ? Graphic.Width : Graphic.Height;

        // rounding-radius = ( rounding-index / 8 ) * ( shorter side / 2 )
        RoundingRadius = (SHORT)(((FLOAT)RoundingIndex / 8) * ((FLOAT)ShorterSide / 2));

        Graphic.RadiusX = RoundingRadius;
        Graphic.RadiusY = RoundingRadius;

        Field.DrawType = DRAW_GRAPHIC;
        Field.Draw.Graphic = Graphic;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^GC
 *        Graphic Circle
 *
 * Description:
 *
 * Format:
 *        ^GCd,t,c
 *
 * Parameters:
 *      d = circle diameter(in dots)
 *      t = border thickness(in dots)
 *      c = line color
 *
 ******************************************************************************/
INT FormatGC(VOID)
{
    INT state;
    _FieldGraphic Graphic;
    SHORT CircleDiameter;

    memset(&Graphic, 0, sizeof(_FieldGraphic));
    CircleDiameter = 3;            // Default Value: 3
    Graphic.Thickness = 1;        // Default Value: 1
    Graphic.Color = 'B';        // Default Value: B
    while (1)
    {
        // Accepted Values: 3 to 4095(larger values are replaced with 4095)
        if (state = ParamUnit(&CircleDiameter, 3, 4095, TRUE))
            break;
        // Accepted Values: 2 to 4095
        if (state = ParamUnit(&Graphic.Thickness, 2, 4095, TRUE))
            break;
        // Accepted Values: B(black) or W(white)
        if (state = ParamChar(&Graphic.Color, "BW", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Graphic.Width = CircleDiameter;
        Graphic.Height = CircleDiameter;
        Graphic.RadiusX = CircleDiameter / 2;
        Graphic.RadiusY = CircleDiameter / 2;
        if (Graphic.Thickness > (CircleDiameter / 2))
            Graphic.Thickness = (CircleDiameter / 2);

        Field.DrawType = DRAW_GRAPHIC;
        Field.Draw.Graphic = Graphic;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^GD
 *        Graphic Diagonal Line
 *
 * Description:
 *
 * Format:
 *        ^GDw,h,t,c,o
 *
 * Parameters:
 *      w = box width(in dots)
 *      h = box height(in dots)
 *      t = border thickness(in dots)
 *      c = line color
 *      o = orientation(direction of the diagonal)
 *
 ******************************************************************************/
INT FormatGD(VOID)
{
    INT state;
    _FieldGraphic Graphic;

    memset(&Graphic, 0, sizeof(_FieldGraphic));
    Graphic.Width = 1;            // Default Value: value of t(thickness) or 3
    Graphic.Height = 1;            // Default Value: value of t(thickness) or 3
    Graphic.Thickness = 1;        // Default Value: 1
    Graphic.Color = 'B';        // Default Value: B
    Graphic.Diagonal = 'R';        // Default Value: R
    while (1)
    {
        // Accepted Values: 3 to 32000
        if (state = ParamUnit(&Graphic.Width, 3, 32000, TRUE))
            break;
        // Accepted Values: 3 to 32000
        if (state = ParamUnit(&Graphic.Height, 3, 32000, TRUE))
            break;
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Graphic.Thickness, 1, 32000, TRUE))
            break;
        // Accepted Values: B(black) or W(white)
        if (state = ParamChar(&Graphic.Color, "BW", TRUE))
            break;
        // Accepted Values: R(or /) = right-leaning diagonal
        //                  L(or \) = left-leaning diagonal
        if (state = ParamChar(&Graphic.Diagonal, "R/L\\", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (Graphic.Width == 1)
            Graphic.Width = Graphic.Thickness;
        if (Graphic.Height == 1)
            Graphic.Height = Graphic.Thickness;

        Field.DrawType = DRAW_GRAPHIC;
        Field.Draw.Graphic = Graphic;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^GE
 *        Graphic Ellipse
 *
 * Description:
 *
 * Format:
 *        ^GEw,h,t,c
 *
 * Parameters:
 *      w = ellipse width(in dots)
 *      h = ellipse height(in dots)
 *      t = border thickness(in dots)
 *      c = line color
 *
 ******************************************************************************/
INT FormatGE(VOID)
{
    INT state;
    _FieldGraphic Graphic;

    memset(&Graphic, 0, sizeof(_FieldGraphic));
    Graphic.Width = 1;            // Default Value: value used for thickness(t) or 1
    Graphic.Height = 1;            // Default Value: value used for thickness(t) or 1
    Graphic.Thickness = 1;        // Default Value: 1
    Graphic.Color = 'B';        // Default Value: B
    while (1)
    {
        // Accepted Values: 3 to 4095(larger values are replaced with 4095)
        if (state = ParamUnit(&Graphic.Width, 3, 4095, TRUE))
            break;
        // Accepted Values: 3 to 4095
        if (state = ParamUnit(&Graphic.Height, 3, 4095, TRUE))
            break;
        // Accepted Values: 2 to 4095
        if (state = ParamUnit(&Graphic.Thickness, 2, 4095, TRUE))
            break;
        // Accepted Values: B(black) or W(white)
        if (state = ParamChar(&Graphic.Color, "BW", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Graphic.RadiusX = Graphic.Width / 2;
        Graphic.RadiusY = Graphic.Height / 2;
        if (Graphic.Thickness > Graphic.Width)
            Graphic.Thickness = Graphic.Width;
        if (Graphic.Thickness > Graphic.Height)
            Graphic.Thickness = Graphic.Height;

        Field.DrawType = DRAW_GRAPHIC;
        Field.Draw.Graphic = Graphic;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^GF
 *        Graphic Field
 *
 * Description:
 *
 * Format:
 *        ^GFa,b,c,d,data
 *
 * Parameters:
 *      a = compression type
 *      b = binary byte count
 *      c = graphic field count
 *      d = bytes per row
 *      data = data
 *
 ******************************************************************************/
INT FormatGF(VOID)
{
    INT state;
    CHAR Type = 'A';        // Default Value: A
    LONG BinaryCount = 0;    // command is ignored if a value is not specified
    LONG GraphicCount = 0;    // command is ignored if a value is not specified
    LONG RowByte = 0;        // command is ignored if a value is not specified

    while (1)
    {
        // Accepted Values: A = ASCII hex, B = binary, C = compressed binary
        if (state = ParamChar(&Type, "ABC", TRUE))
            break;
        // Accepted Values: 1 to 99999
        if (state = ParamNumber(&BinaryCount, PARAM_NUMBER_LONG, 1, 99999))
            break;
        // Accepted Values: 1 to 99999
        if (state = ParamNumber(&GraphicCount, PARAM_NUMBER_LONG, 1, 99999))
            break;
        // Accepted Values: 1 to 99999
        if (state = ParamNumber(&RowByte, PARAM_NUMBER_LONG, 1, 99999))
            break;

        break;
    }

    if (state == PARAM_NULL && FormatStart)
    {
        if (BinaryCount && GraphicCount && RowByte)
            Format.Print |= GraphicField(Type, BinaryCount, GraphicCount, RowByte);

        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^GS
 *        Graphic Symbol
 *
 * Description:
 *
 * Format:
 *        ^GSo,h,w
 *
 * Parameters:
 *      o = font orientation
 *      h = character height proportional to width(in dots)
 *      w = character width proportional to height(in dots)
 *
 ******************************************************************************/
INT FormatGS(VOID)
{
    INT state;
    _FieldFont Font;

    Font.File.Device = _NULL;
    strcpy(Font.File.Name, "GS.FNT");
    Font.Orientation = FieldDef.Orientation;    // Default Value: N or the ^FW value
    Font.Height = FieldDef.Font.Height;            // Default Value: last ^CF value
    Font.Width = FieldDef.Font.Width;            // Default Value: last ^CF value
    while (1)
    {
        // Accepted Values: N, R, I, and B
        if (state = ParamChar(&Font.Orientation, "NRIB", TRUE))
            break;
        // Accepted Values: 0 to 32000
        if (state = ParamUnit(&Font.Height, 0, 32000, TRUE))
            break;
        // Accepted Values: 0 to 32000
        if (state = ParamUnit(&Font.Width, 0, 32000, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_FONT;
        Field.Draw.Font = Font;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatH(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatH))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^HF
 *        Host Format
 *
 * Description:
 *
 * Format:
 *        ^HFd:o.x
 *
 * Parameters:
 *        d = device location of object
 *        o = object name
 *        x = extension
 *
 ******************************************************************************/
INT FormatHF(VOID)
{
    INT state;
    _ObjFile File;

    File.Device = MemoryAlias.R;        // Default Value: R
    strcpy(File.Name, "UNKNOWN.ZPL");    // Default Value: UNKNOWN.ZPL
    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&File.Device))
            break;
        // name Accepted Values: 1 to 8 alphanumeric charaters
        // extension Accepted Value: .ZPL
        if (state = ParamName(File.Name, 1, "ZPL"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        HostFormat(&File);
        return _SUCCESS;
    }

    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^HG
 *        Host Graphic
 *
 * Description:
 *
 * Format:
 *        ^HGd:o.x
 *
 * Parameters:
 *        d = device location of object
 *        o = object name
 *        x = extension
 *
 ******************************************************************************/
INT FormatHG(VOID)
{
    INT state;

    // Device Default Value: search priority
    // Name Default Value: UNKNOWN.GRF
    _ObjFile File = {_NULL, "UNKNOWN.GRF"};

    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&File.Device))
            break;
        // name Accepted Values: 1 to 8 alphanumeric charaters
        // extension Accepted Value: .GRF
        if (state = ParamName(File.Name, 1, "GRF"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        HostGraphics(&File);
        return _SUCCESS;
    }

    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^HH
 *        Configuration Label Return
 *
 * Description:
 *
 * Format:
 *        ^HH
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatHH(VOID)
{
    if (FormatStart)
        ConfigLabel(OUTPUT_RS232);
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^HW
 *        Host Directory List
 *
 * Description:
 *
 * Format:
 *        ^HWd:o.x
 *
 * Parameters:
 *        d = device location to retrieve object listing
 *        o = object name
 *        x = extension
 *
 ******************************************************************************/
INT FormatHW(VOID)
{
    INT state;
    _ObjFile File;

    File.Device = MemoryAlias.R;    // Default Value: R:*.*
    strcpy(File.Name, "*.*");
    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&File.Device))
            break;
        // name Accepted Values: 1 to 8 alphanumeric charaters
        // extension Accepted Value: any extension conforming for Zebra conventions
        if (state = ParamName(File.Name, 10, "*", "FNT", "BAR", "ZPL", "GRF",
                                            "CO", "DAT", "BAS", "STO", "PNG"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        DirectoryList(&File, OUTPUT_RS232);
        return _SUCCESS;
    }

    return _SUCCESS;
}
/******************************************************************************
 *
 * ZPL II Commands ^HY
 *        Upload Graphic
 *
 * Description:
 *
 * Format:
 *        ^HYd:o.x
 *
 * Parameters:
 *        d = device location of object
 *        o = object name
 *        x = extension
 *
 ******************************************************************************/
INT FormatHY(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^HZ
 *        Display Description Information
 *
 * Description:
 *
 * Format:
 *        ^HZd
 *
 * Parameters:
 *        d = display description to return
 *
 ******************************************************************************/
INT FormatHZ(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatI(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatI))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^ID
 *        Object Delete
 *
 * Description:
 *
 * Format:
 *        ^IDd:o.x
 *
 * Parameters:
 *      d = location of stored object
 *      o = object name
 *      x = extension
 *
 ******************************************************************************/
INT FormatID(VOID)
{
    INT state;
    _ObjFile File;

    File.Device = MemoryAlias.R;        // Default Value: R
    strcpy(File.Name, "UNKNOWN.GRF");    // Default Value: UNKNOWN.GRF
    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&File.Device))
            break;
        // name Accepted Values: any 1 to 8 characters name
        // extension Accepted Value: any extension conforming for Zebra conventions
        if (state = ParamName(File.Name, 9, "GRF", "PNG", "FNT", "ZPL",
                                            "DAT", "ZOB", "STO", "BAZ", "*"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        ObjectDelete(File.Device, File.Name);
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^IL
 *        Image Load
 *
 * Description:
 *
 * Format:
 *        ^ILd:o.x
 *
 * Parameters:
 *      d = location of stored object
 *      o = object name
 *      x = extension
 *
 ******************************************************************************/
INT FormatIL(VOID)
{
    INT state;
    _FieldImage Image;

    Image.Type = IMAGE_LOAD;
    Image.File.Device = MemoryAlias.R;        // Default Value: R
    strcpy(Image.File.Name, "UNKNOWN.GRF");    // Default Value: UNKNOWN.GRF
    Image.MultiX = 1;
    Image.MultiY = 1;
    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&Image.File.Device))
            break;
        // name Accepted Values: 1 to 8 alphanumeric characters, extension fixed value: .GRF
        if (state = ParamName(Image.File.Name, 1, "GRF"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_IMAGE;
        Field.Draw.Image = Image;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^IM
 *        Image Move
 *
 * Description:
 *
 * Format:
 *        ^IMd:o.x
 *
 * Parameters:
 *      d = location of stored object
 *      o = object name
 *      x = extension
 *
 ******************************************************************************/
INT FormatIM(VOID)
{
    INT state;
    _FieldImage Image;

    Image.Type = IMAGE_MOVE;
    Image.File.Device = _NULL;    // Default Value: search priority

    // Default Value: if a name is not specified, UNKNOWN is uesd
    strcpy(Image.File.Name, "UNKNOWN.GRF");
    Image.MultiX = 1;
    Image.MultiY = 1;
    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&Image.File.Device))
            break;
        // name Accepted Values: 1 to 8 alphanumeric characters, extension fixed value: .GRF
        if (state = ParamName(Image.File.Name, 1, "GRF"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DrawType = DRAW_IMAGE;
        Field.Draw.Image = Image;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^IS
 *        Image Save
 *
 * Description:
 *
 * Format:
 *        ^ISd:o.x,p
 *
 * Parameters:
 *      d = location of stored object
 *      o = object name
 *      x = extension
 *      p = print iamge after storing
 *
 ******************************************************************************/
INT FormatIS(VOID)
{
    INT state;
    _ObjFile File;
    CHAR SaveType;

    File.Device = MemoryAlias.R;        // Default Value: R
    strcpy(File.Name, "UNKNOWN.GRF");    // Default Value: UNKNOWN.GRF
    SaveType = SAVE_PRINT;                // Default Value: Y
    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&File.Device))
            break;
        // name Accepted Values: 1 to 8 alphanumeric characters
        // extension Accepted Values: .GRF or .PNG
        if (state = ParamName(File.Name, 2, "GRF", "PNG"))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&SaveType, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Format.ImageFile = File;
        Format.SaveType = SaveType;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatJ(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatJ))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^JB
 *        Initialize Flash Memory
 *
 * Description:
 *
 * Format:
 *        ^JBa
 *
 * Parameters:
 *      a = device to initialize
 *
 ******************************************************************************/
INT FormatJB(VOID)
{
    INT state;
    CHAR Device = _NULL;    // Default Value: a device must be specified

    while (1)
    {
        // Accepted Values: B = Flash Card(PCMCIA), E = internal Flash memory
        if (state = ParamChar(&Device, "REBA", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        ObjectDelete(Device, "*.*");
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^JI
 *        Start ZBI (Zebra BASIC Interpreter)
 *
 * Description:
 *
 * Format:
 *        ^JId:o.x,b,c,d
 *
 * Parameters:
 *      d = location of program to run after initization
 *      o = name of program to run after initization
 *      x = extension of program to run after initization
 *      b = console control
 *      c = echoing control
 *      d = memory allocation for ZBI
 *
 ******************************************************************************/
INT FormatJI(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^JJ
 *        Set Auxiliary Port
 *
 * Description:
 *
 * Format:
 *        ^JJa,b,c,d,e,f
 *
 * Parameters:
 *      a = Operational Mode for auxiliary port
 *      b = Application Mode
 *      c = Application Mode start signal print
 *      d = Application Label Error Mode
 *      e = Reprint Mode
 *      f = Ribbon Low Mode
 *
 ******************************************************************************/
INT FormatJJ(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^JM
 *        Set Dots per Millimeter
 *
 * Description:
 *
 * Format:
 *        ^JMn
 *
 * Parameters:
 *      n = set dots per millimeter
 *
 ******************************************************************************/
INT FormatJM(VOID)
{
    INT state;
    CHAR DPM = DotsMillimeter;            // Default Value: last permanently saved value

    while (1)
    {
        // Accepted Values: A = 24 dots/mm, 12 dots/mm, 8 dots/mm or 6 dots/mm
        //                  B = 12 dots/mm,  6 dots/mm, 4 dots/mm or 3 dots/mm
        if (state = ParamChar(&DPM, "AB", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        DotsMillimeter = DPM;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^JS
 *        Change Backfeed Sequence
 *
 * Description:
 *
 * Format:
 *        ^JSb
 *
 * Parameters:
 *      b = backfeed order in relation to printing
 *
 ******************************************************************************/
INT FormatJS(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^JT
 *        Head Test Interval
 *
 * Description:
 *
 * Format:
 *        ^JT####,a,b,c
 *
 * Parameters:
 *      #### = four-digit number of labels printed between head tests
 *      a = manually select range of elements to test
 *      b = first elements to check when parameter a is Y
 *      c = last elements to check when parameter a is Y
 *
 ******************************************************************************/
INT FormatJT(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^JU
 *        Configuration Update
 *
 * Description:
 *
 * Format:
 *        ^JUa
 *
 * Parameters:
 *      a = active configuration
 *
 ******************************************************************************/
INT FormatJU(VOID)
{
    INT state;
    CHAR my_Active;        // Default Value: a value must be specified

    while (1)
    {
        // Accepted Values: F = reload factory values
        //                  R = recall last saved values
        //                  S = save current settings
        if (state = ParamChar(&my_Active, "FRS", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        ConfigurationUpdata(Active);
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^JW
 *        Set Ribbon Tension
 *
 * Description:
 *
 * Format:
 *        ^JWt
 *
 * Parameters:
 *      t = tension
 *
 ******************************************************************************/
INT FormatJW(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^JZ
 *        Reprint After Error
 *
 * Description:
 *
 * Format:
 *        ^JZa
 *
 * Parameters:
 *      a = reprint after error
 *
 ******************************************************************************/
INT FormatJZ(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatK(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatK))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^KD
 *        Select Date and Time Format(for Real Time Clock)
 *
 * Description:
 *
 * Format:
 *        ^KDa
 *
 * Parameters:
 *      a = value of date and time format
 *
 ******************************************************************************/
INT FormatKD(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^KL
 *        Define Language
 *
 * Description:
 *
 * Format:
 *        ^KLa
 *
 * Parameters:
 *      a = language
 *
 ******************************************************************************/
INT FormatKL(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^KN
 *        Define Printer Name
 *
 * Description:
 *
 * Format:
 *        ^KNa,b
 *
 * Parameters:
 *      a = printer name
 *      b = printer description
 *
 ******************************************************************************/
INT FormatKN(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^KP
 *        Define Password
 *
 * Description:
 *
 * Format:
 *        ^KP####
 *
 * Parameters:
 *      #### = mandatory four-digit password
 *
 ******************************************************************************/
INT FormatKP(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatL(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatL))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^LH
 *        Label Home
 *
 * Description:
 *
 * Format:
 *        ^LHx,y
 *
 * Parameters:
 *      x = x-axis position(in dots)
 *      y = y-axis position(in dots)
 *
 ******************************************************************************/
INT FormatLH(VOID)
{
    INT state;
    _Axis Home = LabelHome;

    while (1)
    {
        // Accepted Values: 0 to 32000
        if (state = ParamUnit(&Home.X, 0, 32000, TRUE))
            break;
        // Accepted Values: 0 to 32000
        if (state = ParamUnit(&Home.Y, 0, 32000, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        LabelHome = Home;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^LL
 *        Label Length
 *
 * Description:
 *        The ^LL command defines the length of the label. This command is necessary
 *        when using continuous media (media not divided into separate labels by
 *        gaps, spaces, notches, slots, or holes).
 *
 * Format:
 *        ^LLy
 *
 * Parameters:
 *      y = y-axis position(in dots)
 *
 ******************************************************************************/
INT FormatLL(VOID)
{
    INT state;
    SHORT Length = MaxLabelLength;

    while (1)
    {
        // Accepted Values: 1 to 32000
        if (state = ParamUnit(&Length, 1, 32000, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        ContLabelLength = Length;

        // continuous media
        if (MediaTracking == 'N')
        {
            LabelLength = ContLabelLength;
            SetLabelLength(LabelLength);
        }
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^LR
 *        Label Reverse Print
 *
 * Description:
 *
 * Format:
 *        ^LRa
 *
 * Parameters:
 *      a = reverse print all fields
 *
 ******************************************************************************/
INT FormatLR(VOID)
{
    INT state;
    CHAR Reverse = LabelReverse;

    while (1)
    {
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Reverse, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        LabelReverse = Reverse;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^LS
 *        Label Shift
 *
 * Description:
 *
 * Format:
 *        ^LSa
 *
 * Parameters:
 *      a = shift left value(in dots)
 *
 ******************************************************************************/
INT FormatLS(VOID)
{
    INT state;
    SHORT Shift = LabelShift;

    while (1)
    {
        // Accepted Values: -9999 to 9999
        if (state = ParamUnit(&Shift, -9999, 9999, FALSE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        LabelShift = Shift;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^LT
 *        Label Top
 *
 * Description:
 *
 * Format:
 *        ^LTx
 *
 * Parameters:
 *      x = label top(in dot rows)
 *
 ******************************************************************************/
INT FormatLT(VOID)
{
    INT state;

    // Default Values: a value must be specified or the command is ignored
    SHORT Top = LabelTop;

    while (1)
    {
        // Accepted Values: -120 to 120
        if (state = ParamUnit(&Top, -120, 120, FALSE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        LabelTop = Top;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatM(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatM))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^MC
 *        Map Clear
 *
 * Description:
 *
 * Format:
 *        ^MCa
 *
 * Parameters:
 *      a = map clear
 *
 ******************************************************************************/
INT FormatMC(VOID)
{
    INT state;
    CHAR Clear = MapClear;

    while (1)
    {
        // Accepted Values: Y(clear bitmap) or N(do not clear bitmap)
        if (state = ParamChar(&Clear, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        MapClear = Clear;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^MD
 *        Media Darkness
 *
 * Description:
 *
 * Format:
 *        ^MDa
 *
 * Parameters:
 *      a = media darkness level
 *
 ******************************************************************************/
INT FormatMD(VOID)
{
    INT state;

    // Default Values: If no value id entered, this command is ignored.
    SHORT Darkness = MediaDarkness;

    while (1)
    {
        // Accepted Values: -30 to 30, depending on current value
        if (state = ParamNumber(&Darkness, PARAM_NUMBER_SHORT, -30, 30))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        MediaDarkness = Darkness;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^MF
 *        Media Feed
 *
 * Description:
 *
 * Format:
 *        ^MFp,h
 *
 * Parameters:
 *      p = feed action at power-up
 *      h = feed action after closing printhead
 *
 ******************************************************************************/
INT FormatMF(VOID)
{
    INT state;
    CHAR PowerUp = FeedPowerUp;            // Default Values: platform-dependent
    CHAR CloseHead = FeedCloseHead;        // Default Values: platform-dependent

    while (1)
    {
        // Accepted Values: F = feed to the first web after sensor
        //                  C = (see ~JC definition)
        //                  L = (see ~JL definition)
        //                  N = no media feed
        if (state = ParamChar(&PowerUp, "FCLN", TRUE))
            break;
        // Accepted Values: F = feed to the first web after sensor
        //                  C = (see ~JC definition)
        //                  L = (see ~JL definition)
        //                  N = no media feed
        if (state = ParamChar(&CloseHead, "FCLN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        FeedPowerUp = PowerUp;
        FeedCloseHead = CloseHead;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^ML
 *        Maximun Label Length
 *
 * Description:
 *
 * Format:
 *        ^MLa,b,c,d
 *
 * Parameters:
 *      a = maximun label length(in dot rows)
 *      b = maximun logical paper out counter
 *      c = maximun physical paper out counter
 *      d = maximun ribbon out counter
 *
 ******************************************************************************/
INT FormatML(VOID)
{
    INT state;

    // Default Value: last permanent saved value
    SHORT LabelLength = MaxLabelLength;
    // Default Value: set to one inch longer than twice the label length
    SHORT LogPaperOut = (SHORT)TPH_DPI;
    // Default Value: is set to one  half an inch
    SHORT PhysPaperOut = (SHORT)(TPH_DPI / 2);
    // Default Value: set to one half of a millimeter
    SHORT RibbonOut = (SHORT)(MM_DOT / 2);

    while (1)
    {
        // Accepted Values: 0 to maximun length of label
        if (state = ParamUnit(&LabelLength, 0, MAX_LABEL_LENGTH, TRUE))
            break;
        // Accepted Values: must be greater than the actual label length or the printer 
        //                  indicates a paper out error after each label
        if (state = ParamNumber(&LogPaperOut, PARAM_NUMBER_SHORT, 0, 32000))
            break;
        // Accepted Values: must be greater than the actual notch or hole or the printer
        //                  indicates a paper out condition after each label
        if (state = ParamNumber(&PhysPaperOut, PARAM_NUMBER_SHORT, 0, 32000))
            break;
        // Accepted Values: allows for the ribbon sensors to occasionally get an incorrect
        //                  ribbon reading without causing an error condition
        if (state = ParamNumber(&RibbonOut, PARAM_NUMBER_SHORT,  0, 32000))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        MaxLabelLength = LabelLength;
        MaxLogPaperOut = LogPaperOut;
        MaxPhysPaperOut = PhysPaperOut;
        MaxRibbonOut = RibbonOut;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^MM
 *        Print Mode
 *
 * Description:
 *
 * Format:
 *        ^MMa,b
 *
 * Parameters:
 *      a = desired mode
 *      b = prepeel select
 *
 ******************************************************************************/
INT FormatMM(VOID)
{
    INT state;
    CHAR Mode = 'T';    // Default Value: T
    CHAR Pre = 'Y';        // Default Value: Y

    while (1)
    {
        // Accepted Values: T = Tear-off
        //                  P = Peel-off
        //                  R = Rewind
        //                  A = Applicator(depends on printer model)
        //                  C = Cutter
        if (state = ParamChar(&Mode, "TPRAC", TRUE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Pre, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        PrintMode = Mode;
        Prepeel = Pre;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^MN
 *        Media Tracking
 *
 * Description:
 *
 * Format:
 *        ^MNa
 *
 * Parameters:
 *      a = media being used
 *
 ******************************************************************************/
INT FormatMN(VOID)
{
    INT state;

    // Default Value: a value must be entered or the command is ignored
    CHAR Tracking = _NULL;

    while (1)
    {
        // Accepted Values: N, Y, W, M and A
        if (state = ParamChar(&Tracking, "NYWMA", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        AutoDetectType = (Tracking == 'A' ? 'Y' : 'N');

        if (Tracking && Tracking != 'A')
        {
            MediaTracking = Tracking;
            SetMediaTracking(MediaTracking);
        }

        // continuous media
        if (MediaTracking == 'N')
        {
            LabelLength = ContLabelLength;
            SetLabelLength(LabelLength);
        }
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^MP
 *        Mode Protection
 *
 * Description:
 *
 * Format:
 *        ^MPa
 *
 * Parameters:
 *      a = mode to protect
 *
 ******************************************************************************/
INT FormatMP(VOID)
{
    INT state;

    // Default Value: a value must be entered or the command is ignored
    CHAR Protect = _NULL;

    while (1)
    {
        // Accepted Values: D, P, C, E, S, W, F, X, and M
        if (state = ParamChar(&Protect, "DPCESWFXM", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^MT
 *        Media Type
 *
 * Description:
 *
 * Format:
 *        ^MTa
 *
 * Parameters:
 *      a = media type used
 *
 ******************************************************************************/
INT FormatMT(VOID)
{
    INT state;

    // Default Value: a value must be entered or the command is ignored
    CHAR Type = _NULL;

    while (1)
    {
        // Accepted Values: T = thermal transfer media, D = direct thermal media
        if (state = ParamChar(&Type, "TD", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (Type)
            MediaType = Type;

        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^MU
 *        Set Units of Measurement
 *
 * Description:
 *        The ^MU command sets the units of measurement the printer uses.
 *
 * Format:
 *        ^MUa,b,c
 *
 * Parameters:
 *      a = units
 *      b = format base in dots per inch
 *      c = desired dots-per-inch conversion
 *
 ******************************************************************************/
INT FormatMU(VOID)
{
    INT state;
    CHAR Units = MeasureUnit;    // Default Value: D
    SHORT Format = -1;    // Default Value: a value must be entered or the command is ignored
    SHORT Desired = -1;    // Default Value: a value must be entered or the command is ignored

    while (1)
    {
        // Accepted Values: D = dots, I = inches, M = millimeters
        if (state = ParamChar(&Units,  "DIM", TRUE))
            break;
        // Accepted Values: 150, 200, 300
        if (state = ParamNumber(&Format, PARAM_NUMBER_SHORT, 150, 600))
            break;
        // Accepted Values: 300, 600
        if (state = ParamNumber(&Desired, PARAM_NUMBER_SHORT, 150, 600))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        // ^MU also allows for printing at lower resolutions
        // - 600 dpi printers are capable of printing at 300, 200, and 150 dpi
        // - 300 dpi printers are capable of printing at 150 dpi
        if ((Format == 300 && Desired == 600) || (Format == 200 && Desired == 600) ||
            (Format == 150 && Desired == 600) || (Format == 150 && Desired == 300) ||
        // To turn the conversion off, enter matching values for parameter b and c
            (Format == 150 && Desired == 150) || (Format == 200 && Desired == 200) ||
            (Format == 300 && Desired == 300) || (Format == 600 && Desired == 600))
            ConvertDPI = Desired / Format;
        MeasureUnit = Units;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^MW
 *        Modify Heading Warning
 *
 * Description:
 *
 * Format:
 *        ^MWa
 *
 * Parameters:
 *      a = enable head cold warning
 *
 ******************************************************************************/
INT FormatMW(VOID)
{
    INT state;

    // when a parameter is not given, the instruction is ignored.
    CHAR Head = _NULL;

    while (1)
    {
        // Accepted Values: y = enable head cold warning, n = disable head cold warning
        if (state = ParamChar(&Head, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (Head)
            HeadWarn = Head;

        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatN(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatN))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^NI
 *        Network ID Number
 *
 * Description:
 *
 * Format:
 *        ^NI###
 *
 * Parameters:
 *      ### = network ID number assigned(must be a three-digit entry)
 *
 ******************************************************************************/
INT FormatNI(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^NS
 *        Change Networking Settings
 *
 * Description:
 *
 * Format:
 *        ^NSa,b,c,d
 *
 * Parameters:
 *      a = network setting
 *      b = IP Address
 *      c = Subnet Mask
 *      d = Default Gateway
 *
 ******************************************************************************/
INT FormatNS(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatP(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatP))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^PF
 *        Slew Given Number of Dot Rows
 *
 * Description:
 *
 * Format:
 *        ^PF#
 *
 * Parameters:
 *      # = number of dots rows to slew
 *
 ******************************************************************************/
INT FormatPF(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^PH
 *        Slew to Home Position
 *
 * Description:
 *
 * Format:
 *        ^PH
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatPH(VOID)
{
    if (FormatStart)
    {
        _PrintCfg HomeCfg = *pPrintCfg;

        ToPrintConfig(&HomeCfg);
        FeedBatch(1, &HomeCfg, TRUE, _NULL);
    }
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^PM
 *        Printing Mirror Image of Label
 *
 * Description:
 *
 * Format:
 *        ^PMa
 *
 * Parameters:
 *        a = print mirror image of entire label
 *
 ******************************************************************************/
INT FormatPM(VOID)
{
    INT state;
    CHAR Mirror = 'N';    // Default Values: N

    while (1)
    {
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Mirror, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        LabelMirror = Mirror;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^PO
 *        Print Orientation
 *
 * Description:
 *
 * Format:
 *        ^POa
 *
 * Parameters:
 *        a = invert label 180 degrees
 *
 ******************************************************************************/
INT FormatPO(VOID)
{
    INT state;
    CHAR Orientation = 'N';    // Default Values: N

    while (1)
    {
        // Accepted Values: N(normal) or I(invert)
        if (state = ParamChar(&Orientation, "NI", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        LabelOrientation = Orientation;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^PP
 *        Programmable Pause
 *
 * Description:
 *
 * Format:
 *        ^PP
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatPP(VOID)
{
    if (FormatStart)
        ProgrammablePause();
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^PQ
 *        Print Quantity
 *
 * Description:
 *
 * Format:
 *        ^PQq,p,r,o
 *
 * Parameters:
 *        q = total quantity of label to print
 *        p = pause and cut value(labels between pauses)
 *        r = replicates of each serial number
 *        0 = override pause count
 *
 ******************************************************************************/
INT FormatPQ(VOID)
{
    INT state;
    LONG Quantity = 1;        // Default Value: 1
    LONG PauseCut = 0;        // Default Value: 0(no pause)
    LONG Replicate = 0;        // Default Value: 0(no replicate)
    CHAR Override = 'N';    // Default Value: N

    while (1)
    {
        // Accepted Values: 1 to 99,999,999
        if (state = ParamNumber(&Quantity, PARAM_NUMBER_LONG, 1, 99999999))
            break;
        // Accepted Values: 1 to 99,999,999
        if (state = ParamNumber(&PauseCut, PARAM_NUMBER_LONG, 1, 99999999))
            break;
        // Accepted Values: 0 to 99,999,999
        if (state = ParamNumber(&Replicate, PARAM_NUMBER_LONG, 0, 99999999))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&Override,  "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Format.Quantity = Quantity;
        Format.PauseCut = PauseCut;
        Format.Replicate = Replicate;
        Format.Override = Override;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^PR
 *        Print Rate
 *
 * Description:
 *
 * Format:
 *        ^PRp,s,b
 *
 * Parameters:
 *        p = print speed
 *        s = slew speed
 *        b = backfeed speed
 *
 ******************************************************************************/
INT FormatPR(VOID)
{
    INT state;
    CHAR Print = 'A';                // Default Value: A
    CHAR Slew = 'D';                // Default Value: D
    CHAR Backfeed = 'A';        // Default Value: A

    while (1)
    {
        // Accepted Values: A, B, C, D, and E or 2 to 12
        if (state = ParamSpeed(&Print))
            break;
        // Accepted Values: A, B, C, D, and E or 2 to 12
        if (state = ParamSpeed(&Slew))
            break;
        // Accepted Values: A, B, C, D, and E or 2 to 12
        if (state = ParamSpeed(&Backfeed))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        PrintSpeed = Print;
        SlewSpeed = Slew;
        BackfeedSpeed = Backfeed;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^PW
 *        Print Width
 *
 * Description:
 *
 * Format:
 *        ^PWa
 *
 * Parameters:
 *        a = label width(in dots)
 *
 ******************************************************************************/
INT FormatPW(VOID)
{
    INT state;
    SHORT Width = LabelWidth;            // Default Value: last permanently saved value

    while (1)
    {
        // Accepted Values: 2, to the width of the label
        if (state = ParamUnit(&Width, 2, MAX_LABEL_WIDTH, TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        LabelWidth = Width;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatS(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatS))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SC
 *        Set Serial Communications
 *
 * Description:
 *
 * Format:
 *        ^SCa,b,c,d,e,f
 *
 * Parameters:
 *        a = baud rate
 *        b = word length(in data bits)
 *        c = parity
 *        d = stop bits
 *        e = protocol mode
 *        f = Zebra protocol
 *
 ******************************************************************************/
INT FormatSC(VOID)
{
    INT state;
    LONG BaudRate = _NULL;        // Default Value: must be specified or the parameter is ignored
    SHORT Data = _NULL;            // Default Value: must be specified
    CHAR Parity = _NULL;        // Default Value: must be specified
    SHORT Stop = _NULL;            // Default Value: must be specified
    CHAR Protocol = _NULL;        // Default Value: must be specified
    CHAR ZebraProtocol = _NULL;    // Default Value: must be specified

    while (1)
    {
        // Accepted Values: ...
        if (state = ParamNumber(&BaudRate, PARAM_NUMBER_LONG, 110, 115200))
            break;
        // Accepted Values: 7 or 8
        if (state = ParamNumber(&Data, PARAM_NUMBER_SHORT, 7, 8))
            break;
        // Accepted Values: N(none), E(even), O(odd)
        if (state = ParamChar((CHAR *)&Parity, "NEO", TRUE))
            break;
        // Accepted Values: 1 or 2
        if (state = ParamNumber(&Stop, PARAM_NUMBER_SHORT, 1, 2))
            break;
        // Accepted Values: X(XON/XOFF), D(DTR/DSR), or R(RTS)
        if (state = ParamChar(&Protocol, "XDR", TRUE))
            break;
        // Accepted Values: A = ACK/NAK, N = none, Z = Zebra
        if (state = ParamChar(&ZebraProtocol, "ANZ", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        SetSerialPort(BaudRate, Data, Parity, Stop);
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SE
 *        Select Encoding
 *
 * Description:
 *
 * Format:
 *        ^SEd:o.x
 *
 * Parameters:
 *        d = location of encoding table
 *        o = name of encoding table
 *        x = extension
 *
 ******************************************************************************/
INT FormatSE(VOID)
{
    INT state;
    _ObjFile File;

    File.Device = MemoryAlias.R;    // Default Value: R
    strcpy(File.Name, "");            // Default Value: a value must be specified
    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&File.Device))
            break;
        // name Accepted Values: 1 to 8 alphanumeric characters, extension fixed value: .DAT
        if (state = ParamName(File.Name, 1, "DAT"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (EncodingFile.Device == File.Device && strcmp(EncodingFile.Name, File.Name) == 0)
            return _SUCCESS;

        if (SelectEncoding(&File))
            SaveEncoding(&File);

        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SF
 *        Serialization Field(with a standard ^FD String)
 *
 * Description:
 *        The ^SF command allows you to serialize a standard ^FD string. The
 *        maximum size of the mask and increment string is 3K combined.
 *
 * Format:
 *        ^SFa,b
 *
 * Parameters:
 *        a = mask string
 *        b = increment string
 *
 ******************************************************************************/
INT FormatSF(VOID)
{
    INT state;
    _FieldData Mask;
    _FieldData Increment;

    Mask.Length = 0;
    strcpy(Mask.Content, "");

    // The default value is equivalent to a decimal value of one.
    Increment.Length = 1;
    strcpy(Increment.Content, "");

    while (1)
    {
        // The mask string sets the serialization scheme.
        if (state = ParamData(&Mask, "", "\x0\x0\x0", FALSE))
            break;
        // The increment string is the value to be added to the field on each label.
        if (state = ParamData(&Increment, "", "\x0\x0\x0", FALSE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.Serialization = SERIALIZATION_FIELD;

        strncpy(Field.Mask, Mask.Content, sizeof(Field.Mask));
        Field.Mask[sizeof(Field.Mask) - 1] = '\0';

        strncpy(Field.Increment, Increment.Content, sizeof(Field.Increment));
        Field.Increment[sizeof(Field.Increment) - 1] = '\0';
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SL
 *        Set Mode and Language(for Real-Time Clock)
 *
 * Description:
 *
 * Format:
 *        ^SLa,b
 *
 * Parameters:
 *        a = mode
 *        b = language
 *
 ******************************************************************************/
INT FormatSL(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SN
 *        Serialization Data
 *
 * Description:
 *
 * Format:
 *        ^SNv,n,z
 *
 * Parameters:
 *        v = starting value
 *        n = increment or decrement value
 *        z = add leading zeros(if needed)
 *
 ******************************************************************************/
INT FormatSN(VOID)
{
    INT state;
    _FieldData Data;
    _FieldData Increment;
    CHAR LeadingZero;

    // Default Value: 1
    Data.Length = 1;
    strcpy(Data.Content, "1");

    // Default Value: 1
    Increment.Length = 1;
    strcpy(Increment.Content, "1");

    LeadingZero = 'N';                    // Default Value: N

    while (1)
    {
        // Accepted Values: 12-digits maximun for the portion to be indexed
        if (state = ParamData(&Data, &Field.HexIndicator, Field.ClockIndicator, FALSE))
            break;
        // Accepted Values: 12-digit maximun
        if (state = ParamData(&Increment, "", "\x0\x0\x0", FALSE))
            break;
        // Accepted Values: Y(yes) or N(no)
        if (state = ParamChar(&LeadingZero, "YN", TRUE))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        Field.DataType = FIELD_VARIABLE;
        Field.Serialization = SERIALIZATION_DATA;

        strncpy(Field.Increment, Increment.Content, sizeof(Field.Increment));
        Field.Increment[sizeof(Field.Increment) - 1] = '\0';
        Field.LeadingZero = LeadingZero;
        FieldData = Data;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SO
 *        Set Offset(for Real-Time Clock)
 *
 * Description:
 *
 * Format:
 *        ^SOa,b,c,d,e,f,g
 *
 * Parameters:
 *        a = clock set
 *        b = months offset
 *        c = days offset
 *        d = years offset
 *        e = hours offset
 *        f = minutes offset
 *        g = seconds offset
 *
 ******************************************************************************/
INT FormatSO(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SP
 *        Start Print
 *
 * Description:
 *
 * Format:
 *        ^SPa
 *
 * Parameters:
 *        a = dot row to start printing
 *
 ******************************************************************************/
INT FormatSP(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SQ
 *        Halt ZebraNet Alert
 *
 * Description:
 *
 * Format:
 *        ^SQa,b,c
 *
 * Parameters:
 *        a = condition type
 *        b = destination
 *        c = halt messages
 *
 ******************************************************************************/
INT FormatSQ(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SR
 *        Set Printhead Resistance
 *
 * Description:
 *
 * Format:
 *        ^SR####
 *
 * Parameters:
 *        #### = resistance value(four-digit numeric value)
 *
 ******************************************************************************/
INT FormatSR(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SS
 *        Set Media Sensors
 *
 * Description:
 *
 * Format:
 *        ^SSw,m,r,l,m2,r2,a,b,c
 *
 * Parameters:
 *        w = web(three-digit value)
 *        m = media(three-digit value)
 *        r = ribbon(three-digit value)
 *        l = label length(in dots, four-digit value)
 *        m2 = intensity of media LED(three-digit value)
 *        r2 = intensity of ribbon LED(three-digit value)
 *        a = mark sensing(three-digit value)
 *        b = mark media sensing(three-digit value)
 *        c = mark LED sensing(three-digit value)
 *
 ******************************************************************************/
INT FormatSS(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^ST
 *        Set Date and Time(for Real-Time Clock)
 *
 * Description:
 *
 * Format:
 *        ^STa,b,c,d,e,f,g
 *
 * Parameters:
 *        a = month
 *        b = day
 *        c = year
 *        d = hour
 *        e = minute
 *        f = second
 *        g = format
 *
 ******************************************************************************/
INT FormatST(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SX
 *        Set ZebraNet Alert
 *
 * Description:
 *
 * Format:
 *        ^SXa,b,c,d,e,f
 *
 * Parameters:
 *        a = condition type
 *        b = destination for route alert
 *        c = enable condition set alert to this destination
 *        d = enable condition clear alert to this destination
 *        e = destination setting
 *        f = port number
 *
 ******************************************************************************/
INT FormatSX(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^SZ
 *        Set ZPL
 *
 * Description:
 *
 * Format:
 *        ^SZa
 *
 * Parameters:
 *        a = ZPL version
 *
 ******************************************************************************/
INT FormatSZ(VOID)
{
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatT(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatT))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^TO
 *        Transfer Object
 *
 * Description:
 *
 * Format:
 *        ^TOd:o.x,s:o.x
 *
 * Parameters:
 *        d = source device of stored object
 *        o = stored object name
 *        x = extension
 *        s = destination device of stored object
 *        o = name of the object at destination
 *        x = extension
 *
 ******************************************************************************/
INT FormatTO(VOID)
{
    INT state;

    // Source Default Value:
    // if a drive is not specified, all objects are transferred to the drive set
    //   in destination device
    // if a name is not specified, * is uesd - all objects are select
    _ObjFile SourceFile = {_NULL, "*.*"};
    // Destination Default Value:
    // a destination device must be specified
    // if a name is not specified, the name of the existing object is used
    _ObjFile DestFile = {_NULL, "*.*"};

    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&SourceFile.Device))
            break;
        // name Accepted Values: any existing object conforming to Zebra
        // extension Accepted Value: any extension conforming for Zebra conventions
        if (state = ParamName(SourceFile.Name, 9, "*", "GRF", "PNG", "FNT", "ZPL",
                                                        "DAT", "ZOB", "STO", "BAZ"))
            break;
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&DestFile.Device))
            break;
        // name Accepted Values: up to 8 characters
        // extension Accepted Value: any extension conforming for Zebra conventions
        if (state = ParamName(DestFile.Name, 9, "*", "GRF", "PNG", "FNT", "ZPL",
                                                        "DAT", "ZOB", "STO", "BAZ"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (SourceFile.Device != _NULL && DestFile.Device != _NULL)
            TransferObject(&SourceFile, &DestFile);

        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatW(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatW))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^WD
 *        Print Directory Label
 *
 * Description:
 *
 * Format:
 *        ^WDd:o.x
 *
 * Parameters:
 *        d = source device - optional
 *        o = object name - optional
 *        x = extension - optional
 *
 ******************************************************************************/
INT FormatWD(VOID)
{
    INT state;
    _ObjFile File;

    File.Device = MemoryAlias.R;    // Default Value: R:*.*
    strcpy(File.Name, "*.*");
    while (1)
    {
        // Accepted Values: R:, E:, B:, A: and Z:
        if (state = ParamDevice(&File.Device))
            break;
        // name Accepted Values: 1 to 8 alphanumeric charaters
        // extension Accepted Value: any extension conforming for Zebra conventions
        if (state = ParamName(File.Name, 10, "*", "FNT", "BAR", "ZPL", "GRF",
                                            "CO", "DAT", "BAS", "STO", "PNG"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        DirectoryList(&File, OUTPUT_LABEL);
        return _SUCCESS;
    }

    return _SUCCESS;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatX(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatX))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^XA
 *        Start Format
 *
 * Description:
 *
 * Format:
 *        ^XA
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatXA(VOID)
{
    StartFormat();
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^XB
 *        Suppress Backfeed
 *
 * Description:
 *
 * Format:
 *        ^XB
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatXB(VOID)
{
    if (FormatStart)
        Format.SuppressBack = TRUE;
    return _SUCCESS;
}

/******************************************************************************
 *
 * ZPL II Commands ^XF
 *        Recall Format
 *
 * Description:
 *
 * Format:
 *        ^XFd:o.x
 *
 * Parameters:
 *        d = source device of stored image
 *        o = name of stored image
 *        x = extension
 *
 ******************************************************************************/
INT FormatXF(VOID)
{
    INT state;

    // Device Default Value: search priority(R:, E:, B:, and A:)
    // Name Default Value: if a name is not specified, UNKNOWN is uesd
    _ObjFile File = {_NULL, "UNKNOWN.ZPL"};

    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&File.Device))
            break;
        // Accepted Values: any name up to 8 characters, extension fixed value: .ZPL
        if (state = ParamName(File.Name, 1, "ZPL"))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (File.Device == _NULL)
        {
            // Device Default Value: search priority(R:, E:, B:, and A:)
            if (RunFile(ToFileDevice(MemoryAlias.R), File.Name, 0, _NULL) == _NULL)
            if (RunFile(ToFileDevice(MemoryAlias.E), File.Name, 0, _NULL) == _NULL)
            if (RunFile(ToFileDevice(MemoryAlias.B), File.Name, 0, _NULL) == _NULL)
                RunFile(ToFileDevice(MemoryAlias.A), File.Name, 0, _NULL);
        }
        else
            RunFile(ToFileDevice(File.Device), File.Name, 0, _NULL);

        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^XG
 *        Recall Graphic
 *
 * Description:
 *
 * Format:
 *        ^XGd:o.x,mx,my
 *
 * Parameters:
 *        d = source device of stored image
 *        o = name of stored image
 *        x = extension
 *        mx = magnification factor on the x-axis
 *        my = magnification factor on the y-axis
 *
 ******************************************************************************/
INT FormatXG(VOID)
{
    INT state;
    _FieldImage Image;

    Image.Type = IMAGE_RECALL;

    // Device Default Value: search priority(R:, E:, B:, and A:)
    Image.File.Device = _NULL;

    // Default Value: if a name is not specified, UNKNOWN is uesd
    strcpy(Image.File.Name, "UNKNOWN.GRF");

    Image.MultiX = 1;
    Image.MultiY = 0;    // not specified
    while (1)
    {
        // Accepted Values: R:, E:, B: and A:
        if (state = ParamDevice(&Image.File.Device))
            break;
        // name Accepted Values: 1 to 8 alphanumeric characters, extension fixed value: .GRF
        if (state = ParamName(Image.File.Name, 1, "GRF"))
            break;
        // Accepted Values: 1 to 10
        if (state = ParamNumber(&Image.MultiX, PARAM_NUMBER_SHORT, 1, 10))
            break;
        // Accepted Values: 1 to 10
        if (state = ParamNumber(&Image.MultiY, PARAM_NUMBER_SHORT, 1, 10))
            break;

        state = ParamEnd();
        break;
    }

    if (state == PARAM_SUCCESS && FormatStart)
    {
        if (Image.MultiY == 0)
            Image.MultiY = Image.MultiX;

        // Printing at lower resolutions
        if (MeasureUnit == 'D')
        {
            Image.MultiX *= ConvertDPI;
            Image.MultiY *= ConvertDPI;
            // FIXME: We can not more than 10 times magnification
            if (Image.MultiX > 10)
                Image.MultiX = 10;
            if (Image.MultiY > 10)
                Image.MultiY = 10;
        }

        Field.DrawType = DRAW_IMAGE;
        Field.Draw.Image = Image;
        return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^XZ
 *        End Format
 *
 * Description:
 *
 * Format:
 *        ^XZ
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatXZ(VOID)
{
    if (FormatStart)
        EndFormat();
    return _SUCCESS;
}

/******************************************************************************
 *
 ******************************************************************************/
INT FormatZ(VOID)
{
    _CmdEntry *CmdEntry;
    CHAR cmd;

    do    cmd = ZebraNextByte(NEXT_PARAMETER);
    while (CheckSeparate(cmd) == SEP_LINEFEED);
    if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryFormatZ))
    {
        if (CmdEntry->func() == _SUCCESS)
            return _SUCCESS;
    }
    return _ERROR;
}

/******************************************************************************
 *
 * ZPL II Commands ^ZZ
 *        Printer Sleep
 *
 * Description:
 *
 * Format:
 *        ^ZZt,b
 *
 * Parameters:
 *
 ******************************************************************************/
INT FormatZZ(VOID)
{
    return _ERROR;
}

#endif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值