Path: utzoo!attcan!telly!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!corton!irisa!boissier From: boissier@irisa.fr (franck boissiere) Newsgroups: comp.sys.mac.programmer Subject: Re: Import Binary Date File from PC Message-ID: <1991Feb6.102550.10982@irisa.fr> Date: 6 Feb 91 10:25:50 GMT References: <21958@duke.cs.duke.edu> Sender: news@irisa.fr Organization: IRISA, Rennes (FR) Lines: 43 From article <21958@duke.cs.duke.edu>, by fang@physics.phy.duke.edu (Fang Zhong): > > I use a PC to automate my experiment. I store my data on the PC in > binary format as: > > >> fp = fopen(filename, "ab"); >> fwrite(&data, sizeof(float), 1,fp); >> fclose(fp); > > I can use: > >> fread(&data, sizeof(float), 1, fp); > > to read the data back on PC. I plot my data with Igor on Mac. However, if > I use the same line > >> fread(&data, sizeof(float), 1, fp); > > to read the data on Mac after the data has been imported via "default > translation" of Apple File Exchange, I get garbage. The same is true when > I generate binary data on Mac and read it back on PC. This problem exits > regardless which mode I use in AFE. AFE only knows about file structured following a format. For text files it will map end of lines accordingly for Microsoft Word files it will convert between several other text processing formats. In your case how to you want AFE to know that this particular file contains floats written on a PC and convert them into the proper Mac format? Your problem is that the byte storage of multibyte data is not the same on 80x86 (PC processors) and 680x0 (Mac Processors), the swab() routine included in most C libraries will do the job for you. -- Franck BOISSIERE boissier@irisa.irisa.fr Prototyping Lab Manager boissier@ccettix.UUCP C.C.E.T.T. B.P. 59 boissier%irisa.irisa.fr@uunet.uu.net 35512 CESSON SEVIGNE CEDEX FRANCE