PRB:Subsequent Calls to _pg_chart Toggle Scale Title On or Off

ID Number: Q70250

6.00 6.00a 6.00ax

MS-DOS

buglist6.00 buglist6.00a buglist6.00ax

Summary:

SYMPTOMS

When using the _pg_chart() function in Microsoft C versions 6.0,

6.0a, and 6.0ax and QuickC versions 2.0, 2.01, 2.5, and 2.51, the

title for the scaling factor on the y-axis toggles on and off in

subsequent calls. The scale title should be visible on every call

to _pg_chart().

STATUS

Microsoft has confirmed this to be a problem in C versions 6.0,

6.0a, and 6.0ax and QuickC versions 2.0, 2.01, 2.5, and 2.51

(buglist2.00, buglist2.01, buglist2.50, and buglist2.51). We are

researching this problem and will post new information here as it

becomes available.

More Information:

The structure used for _pg_chart() contains another structure called

"yaxis". Within yaxis is a structure called scaletitle, which includes

a title string for the scaling factor of the y-axis.

The sample code below (a modified QuickC 2.51 sample program called

BUCKLE.C) uses values that are defined to be in a scaling factor of

"thousands." Therefore, _pg_chart() automatically places this scaling

factor as a title in this structure field. However, on subsequent

calls to the _pg_chart() function, the first character in this title

toggles between the letter T and a null character (\0), alternately

defining and nulling out the string.

The result of this problem (as can be seen by running the program) is

that the scaling title is printed every other call to the function,

and on alternate calls, nothing is printed and the graph is shifted to

the left.

To view this problem in CodeView, place a watch on the title string

and its first character with the following commands:

w? env.yaxis.scaletitle.title,s

w? env.yaxis.scaletitle.title[0]

As the calls to _pg_chart() progress, you can see the first element of

this string ("T") changes to the null character ("\0") and back,

causing the title to change from "Thousands" to "" and back.

Sample Code

-----------

/* Compile options needed: none

*/

#include <conio.h>

#include <stdlib.h>

#include <graph.h>

#include <string.h>

#include <pgchart.h>

#define COUNTRIES 5

float _far value[COUNTRIES] = {10042.5F,20014.3F,35.2F,21.3F,32.6F};

char _far *category[COUNTRIES] = {"USSR","GDR","USA","UK","Other"};

short _far explode[COUNTRIES] = {0, 1, 0, 1, 0};

void main()

{

chartenv env;

int i;

if( !_setvideomode( _MAXRESMODE ) )

exit( 1 );

_pg_initchart(); /* Initialize chart system */

_pg_defaultchart( &env, _PG_COLUMNCHART, _PG_PLAINBARS );

strcpy( env.maintitle.title, "Widget Production" );

for( i = 0 ; i < 5 ; i++ )

{

/* This call changes the value */

_pg_chart( &env, category, value, COUNTRIES );

getch();

_clearscreen( _GCLEARSCREEN );

}

_setvideomode( _DEFAULTMODE );

}

Additional reference words: 6.00 6.00a 6.00ax