PRB: M6101 on PG Scatter Charts with Autoscaling Off

Last reviewed: July 17, 1997
Article ID: Q62627
5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50
MS-DOS                      | WINDOWS
kbprg kbprb

The information in this article applies to:

  • Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax
  • Microsoft C/C++ for MS-DOS, version 7.0
  • Microsoft Visual C++ for Windows versions 1.0 and 1.5

SYMPTOMS

If you turn autoscaling off in a presentation graphics scatter chart, your program may fail and display the following error message when you call the _pg_chartscatter() or _pg_chartscatterms() functions:

    run-time error M6101: MATH
    - floating-point error: invalid

CAUSE

This error is occurring because when autoscaling is turned off, there are several variables that need to be set. These variables are automatically determined when autoscale is set to true. The variables are scalefactor, scalemax, scalemin, scaletitle, ticdecimals, ticformat, and ticinterval. Brief descriptions of these variables can be found by searching on _axistype in the online help for the run-time library.

MORE INFORMATION

The following sample code will reproduce the M6101 run-time error. To eliminate the error uncomment the section of code where scalefactor and the other variables are initialized.

/* Compile options needed: none
   Additional libraries needed: GRAPHICS.LIB and PGCHART.LIB
*/

#include <conio.h>
#include <graph.h>
#include <string.h>
#include <stdlib.h>
#include <pgchart.h>

#define ITEMS  5
#define SERIES 2
float _far people[SERIES][ITEMS] = { { 235.F, 423.F, 596.F, 729.F,
                                                  963.F },
                             { 285.F, 392.F, 634.F, 801.F, 895.F }
                                                                 };
float _far profits[SERIES][ITEMS] = { { 0.9F, 2.3F, 5.4F, 8.0F,
                                                             9.3F  },
                               { 4.2F,  3.4F,  3.6F,  2.9F,  2.7F  }
                                                                   };
char  _far *companies[SERIES] = { "Goodstuff,Inc.", "Badjunk & Co." };

void main()
{
    chartenv env;

    if ( !_setvideomode( _MAXRESMODE ) ) /* Find a valid graphics mode */
        exit( 1 );
    _pg_initchart();                 /* Initialize chart system */

    /* Show single-series scatter chart. */
    _pg_defaultchart (&env, _PG_SCATTERCHART, _PG_POINTONLY );
    strcpy( env.maintitle.title, "Goodstuff, Inc." );
    strcpy( env.xaxis.axistitle.title, "Employees" );
    strcpy( env.yaxis.axistitle.title, "Profitability" );

    /* Turn off autoscaling for yaxis to cause error */
    env.yaxis.autoscale=0;

/* Note: to eliminate the error, uncomment the following section */
/*
    env.yaxis.scalefactor=1000;
    env.yaxis.scalemax=1.0;
    env.yaxis.scalemin=0.0;
    env.yaxis.ticdecimals=0x0001;
    env.yaxis.ticformat=0x0001;
    env.yaxis.ticinterval= 0.5;
*/
    /* M6101 run-time error will occur when calling _pg_chartscatter */
    _pg_chartscatter( &env, people[0], profits[0], ITEMS );

    getch();
    _clearscreen( _GCLEARSCREEN );
    _setvideomode( _DEFAULTMODE );
}


Additional reference words: 5.10 6.00 6.00a 6.00ax 7.00 1.00 1.50
KBCategory: kbprg kbprb
KBSubcategory: GraphicsIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.