Jump to content
Software FX Community

Reading Data from Text files


User (Legacy)
 Share

Recommended Posts

Hello,

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

crashes. Whats going wrong?

Example:

OpenDataEx( COD_VALUES, 3, 3 );

CloseData( COD_VALUES );

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

BSTR BFileName = FileName.AllocSysString();

VARIANT Val;

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

Mike

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";

VARIANT Val;

Val.vt = VT_BSTR;

Val.bstrVal = FileName.AllocSysString();

m_pChartFX->GetExternalData( Provider, Val );

--

FP

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.

Guest
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.

 Share

×
×
  • Create New...