Type : CREATION_INTERNE
El script no lee ningún dato fuente. Su finalidad es crear una función reutilizable que, a su vez, escribe datos textuales proporcionados como parámetro en un archivo del sistema de archivos. El origen de los datos procesados por la función es, por lo tanto, externo a este script pero interno a su propia llamada.
| 1 | PROC FCMP outlib=&lib..&cat..&pkg; |
| 2 | |
| 3 | function mcf_string2file(filepath $, string $, mode $); |
| 4 | IF mode='APPEND' THEN fmode='a'; |
| 5 | ELSE fmode='o'; |
| 6 | LENGTH fref $8; |
| 7 | rc=filename(fref,filepath); |
| 8 | IF (rc ne 0) THEN return( -1 ); |
| 9 | fid = fopen(fref,fmode); |
| 10 | IF (fid = 0) THEN return( -1 ); |
| 11 | rc=fput(fid, string); |
| 12 | rc=fwrite(fid); |
| 13 | rc=fclose(fid); |
| 14 | rc=filename(fref); |
| 15 | return(0); |
| 16 | endsub; |
| 17 | |
| 18 | |
| 19 | QUIT; |
| 1 | /* insert the CMPLIB if not already there */ |
| 2 | %let cmpval=%sysfunc(getoption(cmplib)); |
| 3 | %let found=0; |
| 4 | %DO i=1 %to %sysfunc(countw(&cmpval,%str( %(%)))); |
| 5 | %let var=%scan(&cmpval,&i,%str( %(%))); |
| 6 | %IF &var=&lib..&cat %THEN %let found=1; |
| 7 | %END; |
| 8 | %IF &found=0 %THEN %DO; |
| 9 | options insert=(CMPLIB=(&lib..&cat)); |
| 10 | %END; |