Date: Tue, 31 Jan 2006 09:52:47 -0500
Reply-To: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Subject: Re: Random access with FOPEN(), FREAD(), FPOS() and FGET()
Friar Broccoli wrote:
> Hi Mr DeVenezia;
>
> Thank you for taking the time to provide this alterate method for
> reading offset
> directed file structures. Unfortunately I already knew of this method
> for solving this
> problem. I presented my code as an example of a problem that could be
> solved
> with FGet etc.
Variety is a spice unto itself... but some spices are decidedly untasteful.
Note how the record-length and record-type are specified in the FOPEN to
allow you to read past the end of file.
-----------------------------
filename FOO "%sysfunc(pathname(WORK))/foo.txt";
data _null_;
file FOO recfm=N;
do i = 1 to 26;
S = repeat (byte(64+i),6);
put S $CHAR7. @;
end;
run;
data _null_;
length buffer $40;
fid = fopen ('FOO','I',40,'B');
put fid=;
do until (rcread ne 0);
rcread = fread (fid);
rcget = fget(fid,buffer,40);
put rcread= rcget= buffer=;
end;
fid = fclose(fid);
put fid=;
run;
-----------------------------
Have fun maintaining your tangled skein.
Richard A. DeVenezia
http://www.devenezia.com/