diff --git a/Parser/Gmsh.l b/Parser/Gmsh.l index 835450d5182ab3c9ec9c6d3a8c466bb00799ba9a..a7f9d18f1d3c70d0d9e848ebfeaa0cf7d9025606 100644 --- a/Parser/Gmsh.l +++ b/Parser/Gmsh.l @@ -213,7 +213,8 @@ MPI_Rank return tMPI_Rank; MPI_Size return tMPI_Size; Memory return tMemory; -NameFromString return tNameFromString; +NameToString return tNameToString; +N2S return tNameToString; NewModel return tNewModel; Nurbs return tNurbs; @@ -262,7 +263,8 @@ Spline return tSpline; Split return tSplit; Surface return tSurface; Str return tStr; -StringFromName return tStringFromName; +StringToName return tStringToName; +S2N return tStringToName; Sprintf return tSprintf; StrCat return tStrCat; StrReplace return tStrReplace; diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index d2d9e0209f50ffc802e31eb7136535240478cc1d..1f763261b7cce64504c343aed089f910700d31a8 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -152,7 +152,7 @@ struct doubleXstring{ %token tHomology tCohomology tBetti tExists tFileExists %token tGMSH_MAJOR_VERSION tGMSH_MINOR_VERSION tGMSH_PATCH_VERSION %token tGmshExecutableName tSetPartition -%token tNameFromString tStringFromName +%token tNameToString tStringToName %type <d> FExpr FExpr_Single %type <v> VExpr VExpr_Single CircleOptions TransfiniteType @@ -5673,7 +5673,7 @@ StringExpr : { $$ = $1; } - | tStringFromName '[' String__Index ']' + | tNameToString '[' String__Index ']' { $$ = $3; } @@ -5926,8 +5926,8 @@ String__Index : | StringIndex { $$ = $1; } - // Name from any string - | tNameFromString '[' StringExprVar ']' + // Create a name from any string + | tStringToName '[' StringExprVar ']' { $$ = $3; } ; diff --git a/doc/texinfo/gmsh.texi b/doc/texinfo/gmsh.texi index f039dc75566ae20f9691422b453a0e80ae3069dc..bd85794d6ffd351e01251a41d3bf5f429e123455 100644 --- a/doc/texinfo/gmsh.texi +++ b/doc/texinfo/gmsh.texi @@ -1007,6 +1007,7 @@ parsing of the script file: TextAttributes(@var{char-expression}<,@var{char-expression}@dots{}>) | Exists(@var{string}) | Exists(@var{string}~@{ @var{expression} @}) | FileExists(@var{char-expression}) | + StringToName(@var{char-expression}) | S2N(@var{char-expression}) | GetNumber(@var{char-expression} <,@{expression}>) | GetValue("@var{string}", @var{expression}) | DefineNumber(@var{expression}, @var{onelab-options}) | @@ -1047,11 +1048,12 @@ 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), and @code{FileExists} checks if the -file with the given name exists. @code{GetNumber} allows to get the -value of a ONELAB variable (the optional second argument is the default -value returned if the variable does not exist). @code{GetValue} allows -to ask the user for a value interactively (the second argument is the -value returned in non-interactive mode). For example, inserting +file with the given name exists. @code{StringToName} creates a name +from the provided string. @code{GetNumber} allows to get the value of a +ONELAB variable (the optional second argument is the default value +returned if the variable does not exist). @code{GetValue} allows to ask +the user for a value interactively (the second argument is the value +returned in non-interactive mode). For example, inserting @code{GetValue("Value of parameter alpha?", 5.76)} in an input file will query the user for the value of a certain parameter alpha, assuming the default value is 5.76. If the option @code{General.NoPopup} is set @@ -1150,6 +1152,7 @@ Character expressions are defined as: GetString ( @var{char-expression} <,@var{char-expression}>) | GetStringValue ( @var{char-expression} , @var{char-expression} ) | StrReplace ( @var{char-expression} , @var{char-expression} , @var{char-expression} ) + NameToString ( @var{string} ) | N2S ( @var{string} ) | DefineString(@var{char-expression}, @var{onelab-options}) @end example @@ -1177,6 +1180,7 @@ used in non-interactive mode). @code{StrReplace}'s arguments are: input string, old substring, new substring.@footnote{For compatibility with GetDP (@uref{http://getdp.info}), parentheses can be replaced by brackets @code{[]} in @code{Str} and @code{Sprintf}.} +@code{NameToString} converts a variable name into a string. @code{DefineString} allows to define a ONELAB variable in-line. The @var{char-expression} given as the first argument is the default value; this