You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would prove useful in EGSnrc input files to be able to define variables (without having to create a loop with a loop count = 1). We could use the key variable = but otherwise the same syntax as for loop variables. While at it, we should add tokens integer, float, string instead of integers 0, 1, 2 on the value side to specify the variable type.
Patrick Saull suggested to add math for variables, so that an input expression such as
evaluate a*$(var1)+b*$(var2)
would be parsed and replaced by its value. This is not trivial, as it amounts to coding an expression parser; but it would be extremely useful. To this end, we should consider the Shunting Yard and Recursive Descent Parser Algorithms:
Patrick Saull also suggested that variables should be allowed in loop variable definitions, so as to create nested loops where the second loop variable depends on the first one, as in:
loop variable = 0 var2 $(var1) 1
Currently this does not work in EGSnrc input files and results in the following error message:
This discussion was converted from issue #299 on April 16, 2021 16:04.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
It would prove useful in EGSnrc input files to be able to define variables (without having to create a loop with a
loop count = 1
). We could use the keyvariable =
but otherwise the same syntax as for loop variables. While at it, we should add tokensinteger
,float
,string
instead of integers 0, 1, 2 on the value side to specify the variable type.Patrick Saull suggested to add math for variables, so that an input expression such as
would be parsed and replaced by its value. This is not trivial, as it amounts to coding an expression parser; but it would be extremely useful. To this end, we should consider the Shunting Yard and Recursive Descent Parser Algorithms:
https://en.wikipedia.org/wiki/Shunting-yard_algorithm
https://en.wikipedia.org/wiki/Recursive_descent_parser
Patrick Saull also suggested that variables should be allowed in loop variable definitions, so as to create nested loops where the second loop variable depends on the first one, as in:
Currently this does not work in EGSnrc input files and results in the following error message:
Beta Was this translation helpful? Give feedback.
All reactions