Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: How to check the contents of matrix elements in C plugin

From   "Lei Xuan" <[email protected]>
To   <[email protected]>
Subject   st: How to check the contents of matrix elements in C plugin
Date   Tue, 25 Apr 2006 11:02:06 -0500


I copied a piece of C code from online Section 8b, 8d.
to test -SF_mat_el()-.  My question is how I can see/check the contents of
matrix elements.

If I included the following code, given in Section 8d for debugging and
printing out results, the C compiler reported errors (I use Microsoft Visual
C++ 6). I changed "snprintf" to "sprintf", errors are gone, but warnings are
still there. 

/* --------------- Begin change12.c-----------------------------------*/
#include <stdio.h>
#include <string.h>

#include "stplugin.h"

        STDLL stata_call(int argc, char *argv[])         
          char buf[80];
	    ST_double z;
	      snprintf(buf, 80, "The value of z is %lf\n",z);
            return(0) ;

/* --- End change12.c (see\plugins Section 8b) ------*/

Importantly, when running the last line of the following code,
either STATA winddow disappeared, or STATA reported "cannot read memory"

//---------- Begin (Section 8b)----------------------
tempname mymat
mat `mymat'=(1,2 \3,4)
program change12, plugin using("c:\ado\personal\c\changemx.dll")
plugin call change12, `mymat'

// --------- End ------------------------------------

Interestingly, if I don't print out the result, the programs work fine. 
But how can I know programs work correctly?
Thanks a lot,

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index