miser@vms.macc.wisc.edu (Dan Miser) (06/13/89)
Hello net. I've read this group for a long time and have learned much from it. Now I have a question that maybye you could help with. I'm writing a program that concatanates files. However, I cannot write and read to the disk in 512 bytes because I need to use readln and writeln (redirected, of course). I need these because I have to compare string lengths, and check on certain characters inside the string. But, as you guessed this is too slow. I've thought of typecasting, but this doesn't want to work. So, any ideas how I can write in big blocks while still being able to compare string like functions to the file? Thanks in advance. ****************************************************************** ** Dan Miser Phone: (608) 262-0282 ** ** 1210 W. Dayton Madison, WI 53706 ** ** Internet: miser@vms3.macc.wisc.edu Bitnet: miser@wiscmacc ** ******************************************************************
svc@well.UUCP (Leonard Rosenthol) (06/19/89)
In article <1862@dogie.macc.wisc.edu>, miser@vms.macc.wisc.edu (Dan Miser) writes: > I'm writing a program that concatanates files. However, I cannot > write and read to the disk in 512 bytes because I need to use readln > and writeln (redirected, of course). I need these because I have to > compare string lengths, and check on certain characters inside the > string. But, as you guessed this is too slow. I've thought of > typecasting, but this doesn't want to work. > > So, any ideas how I can write in big blocks while still being able to > compare string like functions to the file? > You are not clear what type of 'string comparision' you need to accomplish but assuming it is nothing THAT complex (like grep-type pattern matching) you might consider using the Munger routine to do the search/compares for you. (IM I p.468). Munger is great for doing search/(and optional replace) in a byte stream (which is what you seem to need to do). Since munger takes a handle to a data stream of ANY length, you can read/write in larger chunks using FSRead/FSWrite. If Munger will not handle the searching/comparisons for you, you can still do large writes by using a buffering scheme and then doing one large write rather than the smaller ones. -- +--------------------------------------------------+ Leonard Rosenthol | GEnie : MACgician Lazerware, inc. | MacNet: MACgician UUCP: svc@well.UUCP | ALink : D0025