Skip to content
Snippets Groups Projects
Commit dae995e0 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

new FileExists command to check if a file exists

parent a9bb6a36
No related branches found
No related tags found
No related merge requests found
......@@ -138,6 +138,7 @@ Exists return tExists;
Fabs return tFabs;
Field return tField;
FileExists return tFileExists;
Floor return tFloor;
Fmod return tFmod;
For return tFor;
......
This diff is collapsed.
......@@ -184,22 +184,23 @@
tBetti = 400,
tSetOrder = 401,
tExists = 402,
tGMSH_MAJOR_VERSION = 403,
tGMSH_MINOR_VERSION = 404,
tGMSH_PATCH_VERSION = 405,
tAFFECTDIVIDE = 406,
tAFFECTTIMES = 407,
tAFFECTMINUS = 408,
tAFFECTPLUS = 409,
tOR = 410,
tAND = 411,
tNOTEQUAL = 412,
tEQUAL = 413,
tGREATEROREQUAL = 414,
tLESSOREQUAL = 415,
UNARYPREC = 416,
tMINUSMINUS = 417,
tPLUSPLUS = 418
tFileExists = 403,
tGMSH_MAJOR_VERSION = 404,
tGMSH_MINOR_VERSION = 405,
tGMSH_PATCH_VERSION = 406,
tAFFECTDIVIDE = 407,
tAFFECTTIMES = 408,
tAFFECTMINUS = 409,
tAFFECTPLUS = 410,
tOR = 411,
tAND = 412,
tNOTEQUAL = 413,
tEQUAL = 414,
tGREATEROREQUAL = 415,
tLESSOREQUAL = 416,
UNARYPREC = 417,
tMINUSMINUS = 418,
tPLUSPLUS = 419
};
#endif
/* Tokens. */
......@@ -348,22 +349,23 @@
#define tBetti 400
#define tSetOrder 401
#define tExists 402
#define tGMSH_MAJOR_VERSION 403
#define tGMSH_MINOR_VERSION 404
#define tGMSH_PATCH_VERSION 405
#define tAFFECTDIVIDE 406
#define tAFFECTTIMES 407
#define tAFFECTMINUS 408
#define tAFFECTPLUS 409
#define tOR 410
#define tAND 411
#define tNOTEQUAL 412
#define tEQUAL 413
#define tGREATEROREQUAL 414
#define tLESSOREQUAL 415
#define UNARYPREC 416
#define tMINUSMINUS 417
#define tPLUSPLUS 418
#define tFileExists 403
#define tGMSH_MAJOR_VERSION 404
#define tGMSH_MINOR_VERSION 405
#define tGMSH_PATCH_VERSION 406
#define tAFFECTDIVIDE 407
#define tAFFECTTIMES 408
#define tAFFECTMINUS 409
#define tAFFECTPLUS 410
#define tOR 411
#define tAND 412
#define tNOTEQUAL 413
#define tEQUAL 414
#define tGREATEROREQUAL 415
#define tLESSOREQUAL 416
#define UNARYPREC 417
#define tMINUSMINUS 418
#define tPLUSPLUS 419
......@@ -381,7 +383,7 @@ typedef union YYSTYPE
List_T *l;
}
/* Line 1529 of yacc.c. */
#line 385 "Gmsh.tab.hpp"
#line 387 "Gmsh.tab.hpp"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
......
......@@ -134,7 +134,7 @@ struct doubleXstring{
%token tBSpline tBezier tNurbs tNurbsOrder tNurbsKnots
%token tColor tColorTable tFor tIn tEndFor tIf tEndIf tExit tAbort
%token tField tReturn tCall tFunction tShow tHide tGetValue tGetEnv tGetString
%token tHomology tCohomology tBetti tSetOrder tExists
%token tHomology tCohomology tBetti tSetOrder tExists tFileExists
%token tGMSH_MAJOR_VERSION tGMSH_MINOR_VERSION tGMSH_PATCH_VERSION
%type <d> FExpr FExpr_Single
......@@ -4365,6 +4365,12 @@ FExpr_Single :
$$ = gmsh_yysymbols.count($3);
Free($3);
}
| tFileExists '(' StringExpr ')'
{
std::string tmp = FixRelativePath(gmsh_yyname, $3);
$$ = !StatFile(tmp);
Free($3);
}
| '#' String__Index '[' ']'
{
if(!gmsh_yysymbols.count($2)){
......
This diff is collapsed.
......@@ -983,6 +983,7 @@ parsing of the script file:
StrCmp(@var{char-expression}, @var{char-expression}) |
TextAttributes(@var{char-expression}<,@var{char-expression}@dots{}>) |
Exists(@var{string}) | Exists(@var{string}~@{ @var{expression} @}) |
FileExists(@var{char-expression}) |
GetValue("@var{string}", @var{expression})
@end example
......@@ -1018,7 +1019,8 @@ compares the two strings (returns an integer greater than, equal to, or
less than 0, according as the first string is greater than, equal to, or
less than the second string). @code{TextAttributes} creates attributes
for text strings. @code{Exists} checks if a variable with the given name
exists (i.e., has been defined previously).
exists (i.e., has been defined previously), and @code{FileExists} checks
if the file with the given name exists.
The last case in the definition allows to ask the user for a value
interactively. For example, inserting @code{GetValue("Value of parameter
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment