OpenSees Cloud

OpenSees AMI

Beware the Em Dash

Original Post - 29 Oct 2023 - Michael H. Scott

Visit Structural Analysis Is Simple on Substack.


Out of a rational fear of making a transcription error, no one re-types what they read in a web browser. Instead, they highlight a line or two to initiate the copy-paste-modify sequence.

And somewhere in the annals of OpenSees history, an em dash appeared in the recorder commands of a Tcl example or documentation. After years of copy-pasting, that em dash has been replicated in numerous OpenSees Tcl scripts.

Unfortunately, the em dash is not an ASCII character, but instead is Unicode. As a result, the strcmp functions in the OpenSees recorder commands fail, leading to an error message in some cases. In other cases, there is no error message and you get empty output files.

Look at the difference in dashes before the time argument in the two sets of seemingly identical recorder commands below. The dash in the first recorder command is long while the dash in the second command is short.

wipe
model basic -ndm 1 -ndf 1

node 1 0; fix 1 1
node 2 0

uniaxialMaterial Elastic 1 100

element zeroLength 1 1 2 -mat 1 -dir 1

pattern Plain 1 Linear {
    load 2 4.0
}

recorder Element -file force1.out –time -ele 1 force
recorder Element -file force2.out -time -ele 1 force

recorder Node -file disp1.out –time -node 2 -dof 1 disp
recorder Node -file disp2.out -time -node 2 -dof 1 disp

analysis Static -noWarnings

analyze 10

The difference in dashes is really hard to spot if you’re not looking for it, or don’t know the difference is even an issue. And text editors and IDEs have no problem showing you a mix of ASCII and Unicode characters.

Any way, after you run the above script, you will see that both force1.out and disp1.out are empty files while force2.out and disp2.out contain the expected analysis results.

How do I find the em dashes? In Linux, you can pass the -v argument to the cat command. You will see jibberish in front of time in the recorder commands, and anywhere else you have Unicode characters.

Tcl script viewed in ASCII coding

The cat -v command will also work on Windows in a DOS prompt or PowerShell.

How do I fix the em dash issue? In your text editor or IDE, put the cursor behind the em dash, press the Backspace key, then type a regular dash, or hyphen, -.

Will I face the em dash issue in Python? Yes, you could run into this issue when using OpenSeesPy. But it appears the em dash did not creep into the Python examples; however, that does not mean OpenSeesPy is immune to the em dash.