Skip to Content.
Sympa Menu

opal - [Opal] How do I store strings in variables in Opal?

opal AT lists.psi.ch

Subject: The OPAL Discussion Forum

List archive

[Opal] How do I store strings in variables in Opal?


Chronological Thread 
  • From: "Finn O'Shea" <finn.oshea AT nusano.com>
  • To: opal <opal AT lists.psi.ch>
  • Subject: [Opal] How do I store strings in variables in Opal?
  • Date: Fri, 28 Aug 2020 11:39:14 -0700

I hope this question isn't too basic, but I cannot figure out how to store a string in a variable to be recalled later.

Section A.7 of the manual suggests that the following syntax should work:
STRING TEST1 = "one";

but all references to TEST1 return TEST1 instead of "one".  The following script returns the names of the variables only:
----------------------------------------------------
STRING TEST1 = "one";
STRING TEST2 := "two";

REAL TEST3 = 1.2;
STRING TEST4 = "four";                                                                                              
QA : QUADRUPOLE, L = 0.10, K1 = 1.0, ELEMEDGE = 0.0;

ECHO, TEST1;
ECHO, TEST2;
ECHO, TEST1&TEXT4;
-----------------------------------------------------
The output from opal is:
TEST1
TEST2
TEST1TEST4

That is not what I expected.  I can't find any reference in either the Opal or MAD manuals for a helper function that returns the value of a string variable.

Along the way I discovered that what seems to be a mistake in the manual confusing the commands SHOW and WHAT.
That manual says the following for those functions:
The SHOW statement displays the current attribute values of an object. 

The WHAT statement displays all object names matching a given regular _expression_.   

However, when I run those commands I get the SHOW results for WHAT and vice-versa.  For example, 
SHOW, QA;
WHAT, QA;
WHAT, TEST1;
WHAT, TEST3;

returns (to standard out):
Object names matching the pattern "QA":
QA

QA:QUADRUPOLE;

STRING TEST1="one";

REAL TEST3=1.2000000000000000e+00;

It seems like SHOW is doing what the manual says is the function of WHAT.

Getting back to my original question, the variable TEST1 does appear to contain the string "one", but I can't figure out how to get that value out of the variable.  This isn't a special case for ECHO, this kind of substitution into other commands causes errors because the commands don't know how to interpret the variable name to retrieve the value.  This suggests that maybe what I'm trying to do is not possible, but if that is the case I don't know what to make of section A.7.

Thanks in advance for any assistance,
Finn

P.S. I hope my formatting survives...



Archive powered by MHonArc 2.6.19.

Top of Page