Published on :

Macro AHGtoLocal - File copy to local

This code is also available in: Deutsch Español Français
Attention : This code requires administrator privileges.
The macro checks for the existence of the destination directory (and creates it if necessary via %AHGmkdir), extracts the filename, and uses the 'copy' system command (Windows syntax) via the SYSTASK instruction to perform the copy. It offers an option to open the resulting file.
Data Analysis

Type : EXTERNAL


Manipulation of physical files via the operating system.

1 Code Block
MACRO
Explanation :
Macro definition: default parameter handling, conditional creation of the target directory, synchronous execution of the OS copy command (Windows) and conditional opening of the file.
Copied!
1%macro AHGtoLocal(from,to=,open=0,where=);
2 
3 %IF %AHGblank(&to) %THEN %let to=%AHGtempdir;
4 %IF not %sysfunc(fileexist(&to)) %THEN %AHGmkdir(&to);
5 %local filename;
6 %let filename=%AHGfilename(&from);
7 option xsync;
8 systask command "copy &from &to /y" wait;
9
10 %IF &open=1 %THEN %AHGopenfile(&to\&filename,&where);
11 
12%mend;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.