How To Pass Data to Microsoft Graph Programatically

Last reviewed: August 13, 1997
Article ID: Q129533
3.00 5.00 | 3.00b
WINDOWS   | MACINTOSH
kbinterop kbcode kbole

The information in this article applies to:

  • Microsoft Visual FoxPro for Windows, versions 3.0, 5.0
  • Microsoft Visual FoxPro for Macintosh, version 3.0b

SUMMARY

The APPEND GENERAL command in Visual FoxPro contains a new clause (DATA) that allows you to send data to a Microsoft Graph object programatically in a General Field. This article shows by example how to use it.

MORE INFORMATION

Data sent to Microsoft Graph must be in standard clipboard format. That is, fields must be separated by Tab characters, and records must be separated by carriage returns.

The following sample code uses two tables (Datafile and Grphfile):

  • Datafile contains the data to be graphed. It has five fields, the first of which is a character field that holds the labels for the X axis on the graph. The other four fields are either of type Integer or numeric fields that contain integers.
  • Grphfile contains a General field (mgraph) that stores the graph. This table should contain a record with an embedded Microsoft Graph object; the record pointer should be on this record when the program is run.

NOTE: To make the following code sample more flexible, you could substitute the following code for the number 5 in the FOR loops:

   FCOUNT(<tablename>)

Sample Code

   #DEFINE cr CHR(13)
   #DEFINE tab CHR(9)

   USE datafile IN 1
   USE grphfile IN 2
   SELECT datafile
   cGraphString = ""

   * Build tab-delimited string of field names:
   FOR iCounter = 1 TO 5
      cGraphString = cGraphString  + FIELDS(iCounter) ;
         + IIF(iCounter < 5,tab,cr)
   ENDFOR

   * Concatenate the data, converting numeric fields to character:
   SCAN
         FOR iCounter = 1 TO 5
         cGraphString = cGraphString  + IIF(TYPE(Fields(iCounter))='C',;
            EVALUATE(FIELDS(iCounter)) ;
            ,str(EVALUATE(FIELDS(iCounter)),16,2);
            );
            + IIF(iCounter < 5,tab,cr)
      ENDFOR
   ENDSCAN

   SELECT grphfile
   APPEND GENERAL mgraph DATA cGraphString

NOTE: Under Windows 95 and Windows NT, adding the clause CLASS "MSGraph" to the APPEND GENERAL command causes a new, default graph to be created regardless of any existing graph or other type of object stored in the mgraph field (including if it were empty). You may pass data to a graph object without overwriting the existing formatting by omitting the CLASS clause as above.

Using the following code in the above example creates a new graph under Windows 95 or Windows NT, rather than placing the data into the existing graph:

   APPEND GENERAL mgraph CLASS "MsGraph.Chart" DATA cGraphString


Additional reference words: 5.00 VFoxMac 3.00b 3.00 VFoxWin OLE Chart
Gengraph
KBCategory: kbinterop kbcode kbole
KBSubcategory: FxinteropOle
Keywords : FxinteropOle kbcode kbinterop kbole
Version : 3.00 5.00 | 3.00b
Platform : MACINTOSH WINDOWS


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: August 13, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.