home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!usc!rpi!batcomputer!cornell!rochester!galileo.cc.rochester.edu!uhura.cc.rochester.edu!lhep_ltd
- From: lhep_ltd@uhura.cc.rochester.edu (Leonidas Hepis)
- Subject: Need (TB) template to write file... fast!
- Message-ID: <1993Jan23.051359.21857@galileo.cc.rochester.edu>
- Sender: news@galileo.cc.rochester.edu
- Nntp-Posting-Host: uhura.cc.rochester.edu
- Organization: University of Rochester - Rochester, New York
- Date: Sat, 23 Jan 93 05:13:59 GMT
- Lines: 52
-
- Hello there!
-
- I'm a novice in programming the Macintosh. I'm close to finishing a simple
- application and I need to save a file of bytes. I'm currently using Pascal's
- write/read functions to do so: it takes for ever and the resulting file is twice
- as big as the original file in the computer.
-
- The huge array in the computer's memory is in the form advised in the Pascal
- manual (note for the example: ArraySize = 140,000)
-
- type
- MidiByte = byte;
- SysExFile = file of MidiByte; {this type for the in/out files of Pascal r/w}
-
- SysexArrayType = packed array[0..ArraySize] of Midibyte;
- SysexArrayPtr = ^SysexArrayType;
- SysexArrayHandle = ^SysexArrayPtr;
-
- var
- theOldSysExFile, theNewSysExFile: SysExFile; {for the Pascal i/o routines}
- theOldSysExFileName, theNewSysExFileName: string; {for the Pascal i/o }
-
- hSysexArray: SysexArrayHandle; {the handle to the huge array}
-
- Here's the method I use to save the file. It uses Pascal's read/write.
-
- theNewSysExFileName := newfilename('Name of bulk file to create:');
- if not (theNewSysExFileName = '') then
- {if there was a file path returned, i.e. if no Cancel was pressed}
- begin {THIS IS THE BLOCK THAT TAKES A LOT OF TIME}
- rewrite(theNewSysExFile, theNewSysExFileName);
- for writecount := 1 to count - 1 do {'count' has the # of actual bytes}
- { in the huge array (plus one)}
- write(theNewSysExFile, hSysexArray^^[writecount]);
- close(theNewSysExFile);
- writeln('File saving completed.');
- end;
-
- Is there a novice-proof ;-) method of saving this array onto disk so that it's
- done quickly and efficiently (for 140,000 bytes it writes a file 140K not 275K)?
- Will the method guard against not enough space on disk so that it doesn't write
- over any other files?
-
- Thanks.
-
- -leo
-
- --
- How can I believe in God when every time I get kicked in |Leonidas Hepis
- the pants it hurts ALL THE WAY UP TO THE SPLEEN ?! When |
- that happens to me I see NO Intelligent Divine Designer! |lhep_ltd@uhura
- I see chaos and stars and birds flying around my head :) |.cc.rochester.edu
-