GiD - The personal pre and post processor

Commands accepted by the GiD command.exe

The keywords are as follows:

  • %
  • Shift
  • Rem
  • Chdir (Cd)
  • Del (Delete, Erase)
  • Copy
  • Rename (Ren, Move)
  • Mkdir (Md)
  • Set
  • Echo
  • If
  • Call
  • Goto
  • :
  • Type


Unknown instructions will be executed as from an external file.


Not all the possible parameters and modifiers available in the operating system are implemented in the GiD executable command.exe.


The '@' prefix is also handled, as not showing the command being executed.


Note: At the moment, command.exe is only used in Windows operating systems as an alternative to command.com or cmd.exe. With the GiD command.exe some of the disadvantages of Windows can be avoided (the limited length of parameters, temporary use of letters of virtual units that sometimes cannot be eliminated, fleeting appearance of the console window, etc).


If GiD finds the file command.exe located next to gid.exe , it will be used to interpret the *.bat file of the problem type; if the file command.exe cannot be found, the *.bat file will be interpreted by the windows command.com.
If conflicts appear by the use of some instruction still not implemented in the GiD command.exe , it is possible to rename the command.exe file, so that GiD does not find it, and the operating system command.com is used.


%
Returns the value of a variable.
%number
%name%


Parameters
number
The number is the position (from 0 to 9) of one of the parameters which the *.bat file receives.
name
The name of an environment variable. That variable has to be declared with the instruction "set".


Note: GiD sends three parameters to the *.bat file: %1, %2, %3
%1 is the name of the current project (project_name)
%2 is the path of the current project (c:\a\b\c\project_name.gid)
%3 is path of the problem type (c:\a\b\c\problem_type_name.gid)


For example, if GiD is installed in c:\gidwin, the "problemtype" name is cmas2d.gid and the project is test.gid, located in c:\temp (the project is a directory called c:\temp\test.gid with some files inside), parameters will have the following values:


%1 test
%2 c:\temp\test.gid
%3 c:\gidwin\problemtypes\cmas2d.gid


Note: It is possible that the file and directory names of these parameters are in the short mode Windows format. So, parameter %3 would be: c:\GIDWIN\PROBLE~\CMAS2D.GID.


Examples

echo %1 > %2%1.txt
echo %TEMP% >> %1.txt


Predefined dynamic variables:

CDThe current directory (string).
Example: c:\GiD\problemtypes
CMDCMDLINEThe original command line that invoked the 'command.exe'
Example: C:\GiD\command.exe myProject  c:\Users\gid\myProject.gid c:\GiD\problemtypes\myProblemType.gid
DATEThe current date.
Example: 2021-12-02
RANDOMA random integer number, anything from 0 to 32,767 (inclusive).
Example: 20211

TIME

The current time, with a resolution of cents of seconds.
Example: 20:21:12.02


Shift
The shift command changes the values of parameters %0 to %9 copying each parameter in the previous one. That is to say, value %1 is copied to %0, value %2 is copied to %1, etc.


Parameter
None.


Note: The shift command can be used to create a batch program that accepts more than 10 parameters. If it specifies more than 10 parameters in the command line, those that appear after tenth (%9) will move to parameter %9 one by one.


Rem
Rem is used to include comments in a *.bat file or in a configuration file.


rem[comment]


Parameter
comment
Any character string.


Note: Some comments are GiD commands.


Chdir (Cd)
Changes to a different directory.


chdir[drive:path] [..]
or
cd[drive:path] [..]


Parameters
[drive:path]
Disk and path of the new directory.


[..]
Goes back one directory. For example if you are within the C:\WINDOWS\COMMAND> directory this would take you to C:\WINDOWS>.


Note: When GiD calls the *.bat file, the path of the project is the current path, so it is not necessary to use cd %2 at the beginning of the *.bat file.


Examples

chdir e:\tmp cd ..


Delete (Del, Erase) Command used to delete files and folders permanently from the computer.
delete[drive:][path] fileName [fileName]


Parameters
[drive:][path] fileName [fileName] Parameters that specify the location and the name of the file that has to be erased from disk. Several file names can be given.


Note: Files will be eliminated although they have the hidden or read only flag. Use of wildcards is not allowed. For example del . is not valid. File names must be separated by spaces and if the path contains blank spaces, the path should be inside inverted commas (the short path without spaces can also be used).


Examples

delete %2%1\file.cal
del C:\tmp\fa.dat C:\tmp\fb.dat
del "C:\Program files\test 4.txt"


Copy
Copies one or more files to another location.


copy source [+ source [+ ...]] destination


Parameters
source Specifies the file or files to be copied.
destination Specifies the filename for the new file(s).


To append files, specify a single file for destination, but multiple files for source (using the file1 + file2 + file3 format).


Note: If the destination file already exists, it will be overwritten without prompting whether or not you wish to overwrite it.
File names must be separated by spaces. If the destination only contains the path but not the filename, the new name will be the same as the source filename.


Examples

copy f1.txt f2.txt
copy f1.txt c:\tmp
rem if directory c:\tmp exists, c:\tmp\f1.txt will be created, if it does not exist, file c:\tmp will be created.
copy a.txt + b.txt + c.txt abc.txt


Rename (Ren, Move)
Used to rename files and directories from the original name to a new name.


rename[drive:][path] fileName1 fileName2
Parameter [drive:][path] fileName1 Specifies the path and the name of the file which is to be renamed.
fileName2 Specifies the new name file.


Note: If the destination file already exists, it will be overwritten without prompting whether or not you wish to overwrite it. Wildcards are not accepted (*,?), so only one file can be renamed every time. Note that you cannot specify a new drive for your destination. A directory can be renamed in the same way as if it was a file.


Examples

Rename fa.txt fa.dat
Rename "c:\Program Files\fa.txt" c:\tmp\fa.txt
Rename c:\test.gid c:\test2.gid


Mkdir (md)
Allows you to create your own directories.


mkdir[drive:]pathmd [drive:]path


Parameter
drive: Specifies the drive where the new directory has to be created.
path Specifies the name and location of the new directory. The maximum length of the path is limited by the file system.


Note: mkdir can be used to create a new path with many new directories.


Examples

mkdir e:\tmp2
mkdir d1\d2\d3



Set
Displays, sets, or removes Windows environment variables.


set variable=[string]


Parameters
variable Specifies the environment-variable name.
string Specifies a series of characters to assign to the variable.


Note: The set command creates variables which can be used in the same way as the variables %0 to %9. Variables %0 to %9 can be assigned to new variables using the set command.
To get the value of a variable, the variable has to be written inside two % symbols. For example, if the environment-variable name is V1, its value is %V1%. Variable names are not case-sensitive.


Examples

set basename = %1
set v1 = my text


Echo
Displays messages.


echo [message]


Parameters
message Specifies the text that will be displayed in the screen.


Note: The message will not be visible because the console is not visible, since GiD hides it.Therefore, this command is only useful if the output is redirected to a file (using > or >>). The symbol > sends the text to a new file, and the symbol >> sends the text to a file if it already exists. The if and echo commands can be used in the same command line.


Examples

Echo %1 > out.txt
Echo %path% >> out.txt
If Not Exist %2%1.post.res Echo "Program failed" >> %2%1.err


If
Executes a conditional sentence. If the specified condition is true, the command which follows the condition will be executed; if the condition is false, the next line is ignored.

  • if[not] exist fileName command
  • if [not] string1==string2 command
  • if[not] errorlevel number command


Parameters
not Specifies that the command has to be executed only if the condition is false.
exist file Returns true if file exists.
command Is the command that has to be executed if the condition returns true.
string1==string2 Returns true if string1 and string2 are equal. It is possible to compare two strings, or variables (for example, %1).
errorlevel number Returns true if the last program executed returned a code equal to or bigger than the number specified.


Note: Exist can also be used to check if a directory exists.


Examples

if exist sphere.igs echo File exists >> out.txt
if not exist test.gid echo Dir does not exist >> out.txt
if %1 == test echo Equal %1 >> out.txt




Call

Executes a new program.


call[drive:][path] file [parameters]

Parameter
[drive:][path] file Specifies the location and the name of the program that has to be executed.
parameters Parameters required by the program executed.


Note: The program can be *.bat file, a *.exe file or a *.com file. If the program does a recursive call, some condition has to be imposed to avoid an endless curl.


Examples

call test.bat %1
call gid.exe -n -PostResultsToBinary %1.post.res %1.post.bin


Goto
The execution jumps to a line identified by a label.


goto label


Parameter
label It specifies a line of the *.bat file where the execution will continue. That label must exist when the Goto command is executed. A label is a line of the *.bat file and starts with ":". Goto is often used with the command if, in order to execute conditional operations. The Goto command can be used with the label :EOF to make the execution jump to the end of the *.bat file and finish.


Note: The label can have more than eight characters and there cannot be spaces between them. The label name is not case-sensitive.


Example

goto :EOF
if exist %1.err goto end
...
:end


:
Declares a label.


:labelName


Parameter
labelName A string which identifies a line of the file, so that the Goto command can jump there. The label line will not be executed.


Note: The label can have more than eight characters and there cannot be spaces between them. The label name is not case-sensitive.


Examples

:my_label
:end


Type
Displays the contents of text files.


type[drive:][path] fileName


Parameters
[drive:][path] fileName Specifies the location and the name of the file to be displayed. If the file name contains blank spaces it should be inside inverted commas ("file name").


Note: The text will not be visible because the console is not visible, since GiD hides it Therefore, this command is only useful if the output is redirected to a file (using > or >>). The symbol > sends the text to a new file, and the symbol >> sends the text to a file if it already exists. It is recommended to use the copy command instead of type.
In general, the type command should not be used with binary files.


Examples

type %2%1.dat > %2%1.txt


Redirection of output of a program. The redirection symbols > and >> redirect the standard output (stdout) of a console program, it is possible to redirect also the error output (stderr) to a file adding at the end 2> "your_error_filename" (2 represents the stderr channel)

Examples

%3/your_solver.exe %2/%1.dat > "%2/output.txt" 2> "%2/error.txt"

In the example %1 %2 %3 represent the typical arguments provided to the bat file when starting the calculation from GiD (%1 is the name of the model, %2 the path to this model, %3 the path to the problemtype where your_solver.exe is expected and it receive as argument the full path to its .dat input file, and if the solver print messages to stdout or stderr they will appear in the files output.txt and error.txt respectively.

COPYRIGHT © 2022 · GID · CIMNE