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
 3-byte integers?

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
Mike Buess Posted - 03/12/2003 : 3:14:49 PM
Is it possible to read 3-byte integers from file in Origin C? ReadInt(dd, 3, nInts) or Read(&dd, sizeof(dd)) don't work because there are no 3-byte integer types to use for dd. Is there a way around this?

Mike Buess
Origin WebRing Member
2   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 03/13/2003 : 5:25:46 PM
Thanks, Dave. I may try that. The thing is that Origin's File Utility Module (FUM) handles 3-byte integers just fine. I've obtained some performance gains by rewriting other of my LabTalk routines in OriginC, so I thought I'd try with this one. But perhaps this in an area where I should just leave well enough alone.
quote:
If the platform that wrote the data is different from the platform reading it, you may have to be careful to byte-swap "result" once it has the data in it.
Unfortunately, most of the files I deal with are written on non-Windows platforms (Unix, MacIntosh) so byte-order is a familiar issue.

Thanks again,

Mike Buess
Origin WebRing Member
dlw21 Posted - 03/13/2003 : 09:33:18 AM
Mike,

When I've had non-standard words to read in the past, I've usually done it (on unix platforms) with something like this:

 
char buffer[4] = { \000, \000, \000, \000 };
int result, nread;
nread = read(fd,buffer,3);
if ( nread > 0 ) result = *((int *)buffer);


Note that the key is explicitly asking for the number of bytes, not relying on a built-in type.

If the platform that wrote the data is different from the platform reading it, you may have to be careful to byte-swap "result" once it has the data in it.

I haven't tried the above code in OriginC, so I don't know if it would work. If not, surely you could get it to work as an external DLL (though I am not sure what the VC++ equivalent of read() is).

Good luck with this problem!
Dave



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