LIGGGHTS - Input scripts - how to append string variables

Submitted by martin.kozakovic on Sat, 05/23/2020 - 20:09

By DaveK, Faculty of Science, UJEP
Hello, we were experimenting with string variables lately and find out cool possibility:

As many of you know, when you try to define string variable with spaces, you have to enclose it within quotes. But such definition is not evaluating variables. This simple hack is solution:

variable data1 equal 100
variable data2 equal 200
variable quotes string "'"
variable test_var1 string "${data1} ${data1}"
print "Var1: ${test_var1}"
variable test_var2 string ${quotes}${data1} ${data2}${quotes}
print "Var2: ${test_var2}"
variable test_var2 string ${quotes}${test_var2} ${data1} ${data2}${quotes}
print "Var2: ${test_var2}"

Which evaluates to:
Var1: ${data1} ${data1}
Var2: 100 200
Var2: 100 200 100 200

First variable does not evaluate like expected, but using quotes variable (single ' within double quotes) leads to correct solution.