⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 driver2.c

📁 用汇编语言或高级语言编写的源程序翻译成机器可执行的机器语言程序的工具称为“语言处理程序.
💻 C
📖 第 1 页 / 共 3 页
字号:
			chk_special(mhand2, &i);

		_MemMove(((TEXT FAR *)_HandToPtr(mhand)) + startlen,
			_HandToPtr(mhand2),
		 	i);

		if (endlen)                            // Move the ending ctlchars for the object
	 	{
	    	_MemMove(((TEXT FAR *)_HandToPtr(mhand)) + startlen + i,
		    	endchars,
		    	endlen);
	 	}

		retval.ev_type = 'C';
		retval.ev_length = startlen + i + endlen;
	 	retval.ev_handle = mhand;
     }
     else
	 {
		if (g_graph_width)
		{
			retval.ev_type = 'C';
			i = pblk->p[0].val.ev_length;
			retval.ev_handle = pblk->p[0].val.ev_handle;
			chk_special(retval.ev_handle, &i);
			retval.ev_length = i;
		}
		else		/* Quickly return merely the object		*/
        	_MemMove(&retval, &(pblk->p[0].val), sizeof(Value));
	 }

     ParseExtern(34, &retval);                  // Call the User Procedure

     _RetVal(&retval);							// Return the string back to FoxPro

}

/*----------------------------------------------------------------------+
 |  This routine sets up everything for the document. It parses any     |
 |  elements which have '{#}' or '{#B}' in them and replaces it with    |
 |  the correct information which was not available until now.			|
 +----------------------------------------------------------------------*/
FAR pddocst(ParamBlk FAR *pblk)
{
    int         ctllen=0, bufflen=0, buff2len=0;
    int         j, phlen=0, numlen;
    double      tmargin=0;
    TEXT        ctlchars[1024], buff[1024], numstr[4], pgheight[64];
    TEXT        buff2[64];
    TEXT        found=FALSE, binary=FALSE;


    pdStoreNVal(28, pblk->p[0].val.ev_long);		// Store the document height

    pdCval(5, buff, &bufflen);

    for (j = 0; j < bufflen; j++)					// Replace the form length with
    {                                               // the number of lines per page.
        switch(buff[j])
        {
            case '{':
                found = TRUE;
                break;

            case '}':
                if (found)
                {
                    if (binary)
                    {
                        pgheight[phlen] = pdNval(28);
                        phlen++;
                    }
                    else
                    {
                        numlen = NumToStr(pdNval(28), numstr );

                        _StrCpy(pgheight + phlen, numstr);
                        phlen += numlen;
                    }
                }
                else
                {
                    pgheight[phlen] = buff[j];
                    phlen++;
                }
                found = FALSE;
                break;

            case '#':
                if (found)
                    break;


            case 'B':
                if (found)
                {
                    binary = TRUE;
                    break;
                }

            default:
                pgheight[phlen] = buff[j];
                phlen++;
                break;
        }
    }

	//
	// Calculate Dots per Column, if _pdparms[47] is not 0.  Otherwise,
	// the Horizontal Movement command will move by columns.
	//

	if (pdNval(47))
	{
	    g_viadots = TRUE;

		//
		// The column size is adjusted by two columns here in order to avoid
		// printing in the dead space on the right side of the page.
		//

	    g_dots_col = (double) pdNval(47) / (double) (pblk->p[1].val.ev_long + 2);
	    pdStoreRVal(48, g_dots_col);
	}
	else
	    g_viadots = FALSE;

	if (pdNval(49))
	{
	    bufflen = 0;
		g_graph_width = (int) ((double) pdNval(49) * pdNval(44) * (double) 300);
	    pdStoreNVal(50, g_graph_width);
	}
	else
		g_graph_width = 0;



    pdCval(3,  ctlchars, &ctllen);			// Reset printer
    pdCval(10, ctlchars, &ctllen);          // Orientation
    pdCval(8,  ctlchars, &ctllen);          // Characters Per Inch (CPI)
    pdCval(25, ctlchars, &ctllen);          // Global Style
    pdCval(26, ctlchars, &ctllen);          // Global Stroke
	pdCval(45, ctlchars, &ctllen);			// Font Command

    bufflen = 0;
    pdCval(40, buff, &bufflen);				// Top Margin command

    if (!bufflen)
    {
        pdCval(22, buff2, &buff2len);
        if (!buff2len)
        {
           buff2[0] = 13;
           buff2[1] = 10;
           buff2len = 2;
        }

/*----------------------------------------------------------------------+
 |  If there isn't a Top Margin Command, then output CR+LF for the 		|
 |  number of lines of the top margin.									|
 +----------------------------------------------------------------------*/

        tmargin = pdNval(41);

        for (j=0; j < tmargin; j++)
        {
            _StrCpy(ctlchars+ctllen, buff2);
            ctllen += buff2len;
        }
    }
    else
    {
        _StrCpy(ctlchars+ctllen, buff);
        ctllen += bufflen;
    }

    pdCval(7,  ctlchars, &ctllen);          // Lines Per Inch (LPI)
    _StrCpy(ctlchars + ctllen, pgheight);   // Form length
    ctllen += phlen;



    g_docwidth = pblk->p[1].val.ev_long;
    pdStoreNVal(29, g_docwidth);				// Store the document width

    pdStoreNVal(39, FALSE);						// Set the Bottom of Page flag
    g_bop = FALSE;

    pdStoreNVal(21, FALSE);						// Set the Object printed flag
    pdStoreNVal(27, 1);                         // Set the Line printed flag
    g_sendff = FALSE;
    g_curlin = 1;

    RetBinary(ctlchars, ctllen, 30);			// Call the user procedure.
}


/*----------------------------------------------------------------------+
 |  On completion of the document, this routine gets called.  It does   |
 |  a little cleanup and returns the Reset characters to the printer.	|
 +----------------------------------------------------------------------*/
FAR pddocend()
{
    int		ctllen=0;
    TEXT	ctlchars[1024];

    pdCval(3, ctlchars, &ctllen);		// Reset printer
    g_sendff = g_bop = FALSE;
    if (g_capture != BADHANDLE)
    {
        _FreeHand(g_capture);			// Free the capture buffer handle
        g_capture = BADHANDLE;
    }
    g_caplen = 0;

    RetBinary(ctlchars, ctllen, 38);
}


/*----------------------------------------------------------------------+
 |  On page start, this routine gets called.							|
 +----------------------------------------------------------------------*/
FAR pdpagest()
{
    int         ctllen=0;
    TEXT	ctlchars[1024];

    g_curlin = 1;        				// Reset line counter
    g_sendff = FALSE;
    g_bop = TRUE;                       // We encountered a pagest

    RetBinary(ctlchars, ctllen, 31);	// Call the user procedure.
}



/*----------------------------------------------------------------------+
 |  When the end of page is encountered, pdpageend gets called.  It     |
 |  then decides if is necessary to send out a form feed or to capture  |
 |  the form feed until later.                                          |
 +----------------------------------------------------------------------*/
FAR pdpageend()
{
    int         ctllen=0;
    TEXT	ctlchars[1024];


    g_caplen = 0;           // Clear the capture buffer.


    doff(ctlchars, &ctllen);            // Send the form feed
    if (!g_bop)                         // Capture it?
    {
        if (g_capture == BADHANDLE)
            g_capture = _AllocHand(ctllen);

		else
		{
			if (ctllen > _GetHandSize(g_capture))
				_SetHandSize(g_capture, ctllen);
		}

        _MemMove((TEXT FAR *)_HandToPtr(g_capture),
                    ctlchars, ctllen);

        g_caplen = ctllen;
        ctllen = 0;
    }

    g_bop = FALSE;

    RetBinary(ctlchars, ctllen, 37);		// Call the user procedure.
}


/*----------------------------------------------------------------------+
 |  When the end of a line is encountered, we need to check where we    |
 |  are on the page and send a form feed if necessary.                  |
 +----------------------------------------------------------------------*/
FAR pdlineend()
{
    int		ctllen=0;
    TEXT	ctlchars[1024];

    if (g_curlin >= pdNval(28))		// Last line of the page?
    {
        ctlchars[0] = 0;
        g_curlin = 0;
        g_sendff = FALSE;
    }
    else
    {
        pdCval(22, ctlchars, &ctllen);

        if (ctllen == 0)
        {
            ctlchars[0] = 13;   /* CR   */
            ctlchars[1] = 10;   /* LF   */
            ctllen = 2;
        }

        if (!g_sendff)		// Capture the form feed for now.
        {

           if (g_capture == BADHANDLE)
                g_capture = _AllocHand(ctllen);

           else if ((g_caplen + ctllen) > _GetHandSize(g_capture))
                _SetHandSize(g_capture, ctllen + g_caplen);

           _MemMove(((TEXT FAR *)_HandToPtr(g_capture)) + g_caplen,
                ctlchars, ctllen);

           g_caplen += ctllen;

           ctllen = 0;
        }

        g_curlin++;
    }

    RetBinary(ctlchars, ctllen, 36);		// Call the user procedure
}


/*----------------------------------------------------------------------+
 |  Advance the printer horizontally to the appropriate column.         |
 +----------------------------------------------------------------------*/
FAR pdadvprt(ParamBlk FAR *pblk)
{
    int		ctllen=0, numlen;
    TEXT	ctlchars[1024], numstr[7];
    int		fromcol, tocol;


    tocol = pblk->p[1].val.ev_long;			// Going to this column
    fromcol = pblk->p[0].val.ev_long;		// From this column
    g_curcolumn = tocol;

    g_sendff = TRUE;            // Object was printed

	if (g_curlin)
		ctlchars[0] = 0;
	else
	{
        pdCval(22, ctlchars, &ctllen);

        if (ctllen == 0)
        {
            ctlchars[0] = 13;   /* CR   */
            ctlchars[1] = 10;   /* LF   */
            ctllen = 2;
        }
		g_curlin = 1;
	}



    if (g_caplen)			// Did we capture anything previously?
    {
        _MemMove((TEXT FAR *)ctlchars + ctllen,
            ((TEXT FAR *)_HandToPtr(g_capture)), g_caplen);
        ctllen += g_caplen;
        g_caplen = 0;
    }

    if (tocol != fromcol)
    {
        numlen = ctllen;
        pdCval(23, ctlchars, &ctllen);
        if (!(ctllen == numlen))		// Is there a HMI command?
		{
	    	if (g_viadots)
  				numlen = NumToStr(g_dots_col * (double) tocol, numstr);
			else
            	numlen = NumToStr(tocol, numstr);

	    	_StrCpy(ctlchars + ctllen, numstr);
	    	ctllen += numlen;

            pdCval(24, ctlchars, &ctllen);
        }
	else
	{

            if (fromcol <= tocol)		// Move to the column with spaces.
	    {
		numlen = tocol - fromcol;
		tocol = 0;
	    }
	    else
	    {
		numlen = tocol + 1;
                ctlchars[ctllen] = 0x0D;             /* Carriage Return      */
                tocol = 1;
	    }


            _MemFill(ctlchars+ctllen+tocol, ' ', numlen - tocol);
            ctllen += numlen;

	}
    }
    RetBinary(ctlchars, ctllen, -1);		// Return the string to FoxPro.
}



FoxInfo myFoxInfo[] = {
	{"PDOBJECT",pdobject,2,"C,C"},
	{"PDDOCST",pddocst,2,"I,I"},
	{"PDDOCEND",pddocend,0,""},
	{"PDPAGEST",pdpagest,0,""},
	{"PDPAGEEND",pdpageend,0,""},
	{"PDLINEEND",pdlineend,0,""},
	{"PDADVPRT",pdadvprt,2,"I,I"},
	{"PDONLOAD", pdonload, CALLONLOAD, ""},
        {"PDUNONLOAD", pdonunload, CALLONUNLOAD, ""}
};

FoxTable _FoxTable = {
	(FoxTable FAR *)0, sizeof(myFoxInfo) / sizeof(FoxInfo), myFoxInfo
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -