Jump to content
Software FX Community

Reading Data from Text files

User (Legacy)

Recommended Posts


I'm trying to read data from a textfile, but calling GetExternalData

crashes. Whats going wrong?


OpenDataEx( COD_VALUES, 3, 3 );

CloseData( COD_VALUES );

CString FileName = "Path\\test.txt";

BSTR BFileName = FileName.AllocSysString();


Val.vt = VT_BSTR;

Val.bstrVal = BFileName;

ChartP->GetExternalData( Val );

::SysFreeString( BFileName );

Data File test.txt:

12 14 17

15 5 2

9 20 12

the values are separeted with tabs.

I also tried csv files, the values are separated with commas, but the effect

was the same.

Thanks for your help


Link to comment
Share on other sites

GetExternalData doesn't receive a file name. Please check the docs, it

receives a Data Provider object.

If you want to read for a Text File you need to do:

CString ProviderName = "CfxData.File";

VARIANT Provider;

Provider.vt = VT_BSTR;

Provider.bstrVal = ProviderName.AllocSysString();

CString FileName = "d:\\temp\\data.txt";


Val.vt = VT_BSTR;

Val.bstrVal = FileName.AllocSysString();

m_pChartFX->GetExternalData( Provider, Val );



Software FX, Inc.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...