exec_ec - ObjectVision/GeoDMS GitHub Wiki
File, Folder and Read functions exec(ute)_ec(errorcode)
- exec_ec(command line)
- exec_ec(command line, current folder path)
- exec_ec(application name, command line, current folder path)
executes the command line argument and returns it's ExitCode,
It does so by calling CreateProcessA(application name, command line, NULL, NULL, TURE, 0, NULL, NULL, zeroes, zeroes) where application name is NULL when not specified, in which case the application to start is derived from the command line. Once started, command line is what the child process will see when calling GetCommandLine(). See also: Environment.cpp.
When no current folder path is specified, the current folder is inherited from the GeoDms process, which usually is set to the project folder of the last loaded configuration.
You can use such result in the construction of a storage name of a data source which guarantees that it will only be known after completion of that process.
- command with string value type
This example shows how to use the exec_ec function to make a list of files in a folder and store the resulting list in a text file, that can be used later in the process to read all files from the folder.
The CanGenerate parameter can be used in your expression to process all files, making sure the list of files or an error code is generated first.
container folderinfo
{
container impl
{
parameter<string> FileNameDirInfo := '%LocalDataProjDir%/dirinfo_' + date +'.str';
parameter<string> DirCmdOrg := Expand(., 'Dir '+ XmlDir +'/*.xml > ' + FileNameDirInfo);
parameter<string> DirCmd := Replace(DirCmdOrg, '/', '\\') + ' /B';
}
parameter<uint32> writeFileList :=
exec_ec(Expand(., '%env:ComSpec%'), '/c ' + impl/DirCmd, Expand(., '%LocalDataProjDir%'));
parameter<bool> CanGenerate := writeFileList== 0;
}