The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 import binary file problem

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
maxim_n Posted - 11/15/2004 : 3:08:23 PM
Origin Version (Select Help-->About Origin): v.7.5853(B853)
Operating System: WindowsXP Pro

Hello,

Code written below was working perfectly for OriginPro 7 SR0, but it does not import file for the current version of Origin (see above). Does anyboly have an idea what might be wrong? It looks like program can not open image file.

CODE:::

BYTE Buffer[5000000];
Dataset ds;
ds.Attach("Curves", 0);
ds.SetSize(40);
for(i=0; i<40; i++)
ds[i]=0.2*i-4;
ds.Detach();
ds.Attach("Curves",1);
ds.SetSize(40);
FileName.Format("c:\\temp\\spectr\\m%d_ori.sf0", FileIndex);
if (!ImageFile.Open(FileName, file::modeRead))
{
ImageFile.Close();
return;
}
ImageFile.Read(Buffer, 5000000);
ImageFile.Close();
for (Point = 0; Point < 1; Point++)
{
for (i=0;i<40;i++)
{
BYTE h, l;
short a;
a = Buffer[i*2*2500 + Point*2]*256 + Buffer[i*2*2500 Point*2 + 1];
ds[i] = a;
}
}
:::
4   L A T E S T    R E P L I E S    (Newest First)
maxim_n Posted - 11/17/2004 : 3:30:18 PM
Thank's a lot. file::GetLastError command really helped.
eparent Posted - 11/17/2004 : 09:53:16 AM
To find out why the file::Open method failed you need to call the file::GetLastError method. The error codes and descriptions are defined at the top of Origin C's file.h.


maxim_n Posted - 11/16/2004 : 5:56:54 PM
Origin Version (Select Help-->About Origin): v.7.5870(B870)
Operating System: WindowsXP Pro

I wrote function for testing whether the file is opening or not, the answer is always "Failed to open file ...". Function OpenFile() was taken from the example.

Complete code:::

#include <Origin.h>
///////////////
int OpenFile(string strFileName);
void LoadSPImage(int FileIndex);

///////////////
file fScan;
string strFileName;

///////////////
int OpenFile(string strName)
{
strFileName = strName;
if( fScan.Open(strFileName, file::modeRead) )
{
printf("Opened file %s\n", strFileName);
return 0;
}
printf("Failed to open file %s\n", strFileName);
return 1;
}

void LoadSPImage(int FileIndex)
{
string FileName;
FileName.Format("c:\\temp\\spectr\\m%d_ori.sf0",FileIndex);
OpenFile(FileName);
fScan.Close();
}

Please tell me why file is failing to open?
eparent Posted - 11/15/2004 : 3:27:20 PM
Where is the declaration for ImageFile?
Did the call to ImageFile.Open succeed?
Did the call to ImageFile.Read succeed?

More information is needed to diagnose the problem.



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000