Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!netcom!resnicks From: resnicks@netcom.COM (Steve Resnick) Newsgroups: comp.os.msdos.programmer Subject: Re: basic to pascal (mks$ in particular) Message-ID: <28081@netcom.COM> Date: 13 Mar 91 17:53:59 GMT References: <1991Mar12.203014.14472@csrd.uiuc.edu> <2065@gold.gvg.tek.com> <1991Mar13.051427.18507@csrd.uiuc.edu> Organization: Me? Organized? You gotta be kidding! Lines: 54 In article <1991Mar13.051427.18507@csrd.uiuc.edu> leung@sp17.csrd.uiuc.edu (Bruce Leung) writes: >shaunc@gold.gvg.tek.com (Shaun Case) writes: >>leung@sp1.csrd.uiuc.edu (Bruce Leung) writes: >>>I'm trying to read a data file that was written using the mks$ function >>>in Basic. Actually, I assume it was written using that since the only >>>code I have is a Basic program to read the file (shown below). >> >>Perhaps you could modify the code you have to read in the data, >>then print it back out as strings. If so, then you can read it >>in in C or Pascal and convert it that way, once. > >That would work but I don't want to convert the files. I want to be able >to read the files that are created by another program, possibly manipulate >the data, and write it back. Using Basic is not an option. > >The problem is that Turbo Pascal uses 6 bytes for the REAL type. I tried >using the SINGLE type that uses 4 bytes (yes, I have a coprocessor) but >wasn't successful. It is quite likely I was doing something wrong. (Hence >my request to the collective net wisdom.) > >>If you want to use C, take a look at fscanf(), or better yet, >>fgets() and sscanf(). > >I'm familiar with C. To tell you the truth, I haven't tried C yet (head >hung in shame) since I do want to do this in Turbo Pascal. > No shame needed. As I pointed out to Bruce in a reply message, Microsoft GW-BASIC, QuickBASIC V1-3, IBM BASIC, IBM BASICA and older IBM BASIC compilers use the Microsoft Binary Format. (mbf). If you need to convert these numbers using a non-Microsoft compiler, you need to "hand-convert" the numbers. Most other compilers, (Borland, MSC, etc) use IEEE floating point format rather than Microsofts (for obvoius reasons (-:) Microsoft, does, however, provide the information to do the conversion to IEEE format, or, alternatively, you can use Microsoft C V 5+ to do the conversion (there is library support for this), just call 'em up and they will send it to you ... Cheers! Steve -- ------------------------------------------------------------------------------- resnicks@netcom.com, steve@camphq, IFNA: 1:143/105.0, USNail: 530 Lawrence Expressway, Suite 374 Sunnyvale, Ca 94086 - In real life: Steve Resnick. Flames, grammar and spelling errors >/dev/null 0x2b |~ 0x2b, THAT is the question. The Asylum OS/2 BBS - (408)263-8017 12/2400,8,1 - Running Maximus CBCS 1.2 -------------------------------------------------------------------------------