how to export a variable values from TRACE32 - debugging

My question is how to export a variable value which I have seen in watch window? I need to append the values of that variable in Excel format, I'm using the TRACE32 software.

You can export variables to a CSV file as displayed in the Var.WATCH window with command Var.EXPORT. Each variable will get its own line in the CSV. To ensure that only the data and not also the command Var.EXPORT gets part of the result use the command WinPOS ,,,,,0 before Var.EXPORT.
E.g. to export the scalar variables x and y to a CSV file including the type information you can use the commands:
WinPOS ,,,,,0
Var.EXPORT myfile.csv %Hex %Type x y

You can write / append to a file using OPEN, WRITE and CLOSE. Every Spreadsheet program can read CSV and it's easy to write:
OPEN #1 <file name> /Create
WRITE #1 "," Var.VALUE(<variable name>)
CLOSE #1
Writing to a Microsoft Excel file, e.g. XLSX is much more complicated, there are libraries for this in other languages, but I don't think there's anything in TRACE32.
If you want to write it manually you can look into adding a custom button (MENU.AddTool), otherwise you'll need to specify your condition(s).

Related

Using Write command to create new syntax - problem with unwanted spaces

I am trying to run a command on a list of variables stored as values in a different file. To do that I am creating a new syntax based on the variable names, like this:
WRITE OUT="\Selection.sps"
/"VARIABLE ATTRIBUTE VARIABLES = Final_",Var1," ATTRIBUTE=selectVars('yes')." .
EXECUTE.
The Problem is between Final and Var1, I am getting 11 spaces. The file in which I want to use this macro has variable names as Final_Var1 (So in the new file, Final is added to each variable's Name). How can I remove the space so that the new variable can be referred to properly? Should I create a new file or COMPUTE and CONCAT commands?
The write command is limited like that - you can't avoid the spaces or use trim. For commands like the one you're working on there is no way to build the command within the write command - you have to build the text in advance and then put it in the write command, so -
strimg mycmd(a100).
compute mycmd=concat("VARIABLE ATTRIBUTE VARIABLES = Final_",
ltrim(string(Var1,f4)),
" ATTRIBUTE=selectVars('yes').").
WRITE OUT="\Selection.sps" /mycmd .
exe.
Note that this is not the only way to work on variable lists - you can use Python code within the syntax to build your variable lists more efficiently.
I have found a temporary solution, in order to remove the spaces from the variables, I am creating a new variable using:
*Add a variable to use in .sps file.
NUMERIC A(F4).
COMPUTE A = Var1.
ALTER TYPE A (A25).
STRING CMD (A100).
COMPUTE CMD = CONCAT("VARIABLE ATTRIBUTE VARIABLES = Final_", LTRIM (A) , ATTRIBUTE=selectVars('yes').").
EXECUTE.
WRITE OUT="File location\Selection.sps" /CMD.
EXECUTE.
and now a macro can be created using Selection.sps.
If a simpler way exists, please let me know!

How to obtain variable values from a text file for use by a bash script?

I have a bash script, and I'd like it to read in the values of variables from a text file.
I'm thinking that in the text file where the values are stored, I'd use a different line for each variable / value pair and use the equals sign.
VARIABLE1NAME=VARIABLE1VALUE
VARIABLE2NAME=VARIABLE2VALUE
I'd then like my bash script to assign the value VARIABLE1VALUE to the variable VARIABLE1NAME, and the same for VARIABLE2VALUE / VARIABLE2NAME.
Since the syntax of the file is the syntax you would use in the script itself, the source command should do the trick:
source text-file-with-assignments.txt
alternately, you can use . instead of source, but in a case like this, using the full name is more clear.
The documentation can be found in the GNU Bash Reference Manual.

Wrong number format when opening ASCII with labtalk origin9.1

I have a problem reading ASCII-Files into Origin9.1. My ASCII-File looks like below: (note that I have 1 space before , 2 spaces between and 1 space after the numbers)
C:\amiX_TimeHist_P1.dat:
0,19325E-02 0,10000E+00
0,97679E-11 0,99997E-11
0,19769E+10 0,10025E+00
0,39169E+00 0,11636E+00
0,47918E+00 0,13156E+00
later I want to do the following with a scr-File but for now I write the following in Origin2015 in the Script-LabTalk-window:
open -w C:\amiX_TimeHist_P1.dat;
That command works but the numbers I get are in a wrong format:
When I read the file with the Import-wizzard or with ASCII-Import I can choose several options to fit the numbers correctly in the my columns. But this has to be done automatically.
Is there a way to read an ASCII-File uncluding setting parameters when using a script?
Instead of open you should use impASC to import ASCII data. Then you can specify some options to the command. In your case the following should work:
impASC fname:=C:\amiX_TimeHist_P1.dat options.FileStruct.DataStruct:=2 options.FileStruct.MultipleDelimiters:=" " options.FileStruct.NumericSeparator:=1;
If you just type impASC in your script window, in the following dialog box you can edit the import options and display the corresponding skript command.

Shell script that passes parameter to gnuplot does not export the diagram (epslatex)

I have created a shell script (.run) that accepts the prefix for the names of the pictures as a parameter, and then calls gnuplot. However, for some reason, the picture is not saved. The code is:
#!/bin/sh
molecule=$1
echo "Plotting DFT-ADF PY results for $molecule"
echo "Tranmission plot (negatory SO)"
gnuplot -p << EOF
#!/usr/bin/gnuplot
set terminal epslatex size 5,3 color colortext
set output '$molecule_trans.tex'
plot cos(x) w l title 'cos(x)', sin(x) w l title 'sin(x)'
EOF
For my bachelor thesis I have to make several plots that are the same. Additionally, the computational cluster uses a qeueing system. For the purpose of being true to this system, I have created several shell scripts that automatically do stuff. In particular, about 45 simulations are called by the shell scripts, followed by a shell script that enters each simulations' directory and uses python files to evaluate the data into [.dat] files. Next, it should use a gnuplot file to make the graph. I use EPSLaTeX to make my figures, because it is so much nicer. However, in the current implementation this required me to manually edit the various latex files to rename the pictures.
In case you'll need more variables and do not want a $1, $2... mess:
You must use brackets around the variable name
set output '${molecule}_trans.tex'
because the underscore is a valid character for variable names, and bash looks for the variable $molecule_trans, see http://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion.

Putting to a Filename named after a variable

I am using Put (>>) to store information that I am obtaining in Mathematica. The problem is that I am putting a several variables. However, if I do the following, it outputs to a file called year rather than my variable.
For example:
year=64;
sortedTally>>year;
This exports to a file named year rather than a file named 64. The documentation notes that expr >> filename is equivalent to expr >> "filename". Is there any way to circumvent this and put to a filename that changes based on the variables? This is similarly reiterated in the documentation file on Operator Input Forms (at the bottom).
In this case you need to use Put[sortedTally, ToString[year]].

Resources