Published on :
Administration CREATION_INTERNE

System File Creation Macro

This code is also available in: Deutsch Español Français
Awaiting validation
Attention : This code requires administrator privileges.
This macro creates a physical file on the server if it does not already exist. It handles two addressing modes: either by a full path (fullname), or by a directory/filename combination. It relies on the 'X' command to execute a system 'echo', which requires the XCMD option to be enabled. It also depends on probable external macros (%AHGtempdir, %AHGblank).
Data Analysis

Type : CREATION_INTERNE


The file content is generated from the string passed in the 'str' parameter.

1 Code Block
MACRO Data
Explanation :
Defines the AHGcreatefile macro which checks for the existence of the target file. If the file is absent, it executes a system command to write the content of the &str variable into the specified file.
Copied!
1%macro AHGcreatefile(
2dir=%AHGtempdir,
3filename=,
4fullname=,
5str=%str());
6 %IF %AHGblank(&fullname) and not %sysfunc(fileexist(&dir/tmp&filename..tmp)) %THEN x "echo ""&str"" >&dir/tmp&filename..tmp";
7 %ELSE %IF not %AHGblank(&fullname) and not %sysfunc(fileexist(&fullname)) %THEN x "echo ""&str"" >&fullname"
8 ;
9%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.