How Do I Set a Dynamic Name for an Input/Output File? (Magic xpa 3.x)
When you create or use an input/output file in Magic xpa, you have several options for coding the file name:
-
You can hard-code the file name, such as 'C:\Temp\Report.txt'.
-
You can use variables to hold the file name, such as TRIM(AF). The variable, AF, might have been held in a table, or it might have been a file name selected or typed in by the user. You can also generate the file name randomly and hold it in a variable, which is useful for temporary text files.
-
You can use logical names to set all or part of the file name. This is a good idea for the path name, as you want to be able to set the path names at runtime. An especially useful logical name is %TempDir%, which is automatically set up by Magic xpa.
In all cases, the file name will be entered in the Expression Editor. Here we will show you how to do it step by step for a text output file.
-
First, open up the task which is doing the I/O. You can do that by clicking on the task in the navigator pane (Alt+F1).
-
Press Ctrl+I (Task->I/O Devices). This will take you to a list of your I/O devices. If you don’t already have one in the task:
-
Now, tab to the Expression column and zoom (F5, double-click) to the Expression Editor.
-
Enter the expression you want to use for the file name. In this case we used '%TempDir%Orders.txt'. You can use any combination of logical names and variables as long as it evaluates to a valid path name.
Now, when the export runs, the file will be created in the Windows temporary directory in My Computer.
How Do I Format an Expression in the Expression Window?
How Do I Read and Write Files from/to the Directory of the Project?
The Online and Rich Client Samples projects (program EN04 and REN04)