1
0
mirror of https://github.com/sasjs/core.git synced 2025-12-10 22:14:35 +00:00

fix: ensuring sufficient lrecl in mf_getuniquefilref

This commit is contained in:
munja
2022-04-27 23:04:55 +01:00
parent 9ea6c875f2
commit c83ea705a2

View File

@@ -28,15 +28,17 @@
be 8 characters, so a 7 letter prefix would mean `maxtries` should be 10. be 8 characters, so a 7 letter prefix would mean `maxtries` should be 10.
if using zero (0) as the prefix, a native assignment is used. if using zero (0) as the prefix, a native assignment is used.
@param [in] maxtries= (1000) the last part of the libref. Must be an integer. @param [in] maxtries= (1000) the last part of the libref. Must be an integer.
@param [in] lrecl= (32767) Provide a default lrecl with which to initialise
the generated fileref.
@version 9.2 @version 9.2
@author Allan Bowe @author Allan Bowe
**/ **/
%macro mf_getuniquefileref(prefix=_,maxtries=1000); %macro mf_getuniquefileref(prefix=_,maxtries=1000,lrecl=32767);
%local rc fname; %local rc fname;
%if &prefix=0 %then %do; %if &prefix=0 %then %do;
%let rc=%sysfunc(filename(fname,,temp)); %let rc=%sysfunc(filename(fname,,temp,lrecl=&lrecl));
%if &rc %then %put %sysfunc(sysmsg()); %if &rc %then %put %sysfunc(sysmsg());
&fname &fname
%end; %end;
@@ -47,7 +49,7 @@
%do x=0 %to &maxtries; %do x=0 %to &maxtries;
%let fname=&prefix%substr(%sysfunc(ranuni(0)),3,&len); %let fname=&prefix%substr(%sysfunc(ranuni(0)),3,&len);
%if %sysfunc(fileref(&fname)) > 0 %then %do; %if %sysfunc(fileref(&fname)) > 0 %then %do;
%let rc=%sysfunc(filename(fname,,temp)); %let rc=%sysfunc(filename(fname,,temp,lrecl=&lrecl));
%if &rc %then %put %sysfunc(sysmsg()); %if &rc %then %put %sysfunc(sysmsg());
&fname &fname
%return; %return;