0

I found an example, with

READ #1 "filename.hex" &data

were &data is a PRACTICE macro. I need to parse this data. As it is stored in a macro, I am not able to. Is it possible to store it in a PRACTICE variable? If so what would the command look like?

Dennis Kriechel
  • 3,719
  • 14
  • 40
  • 62
dottruce
  • 13
  • 4

1 Answers1

0

You can not read data from a file and store it to a PRACTICE variable directly. However you can read the data to a PRACTICE macro and assign the content of the macro to a PRACTICE variable:

PRIVATE &data                     // declare macro
VAR.NEWGLOBAL char[64] \mydata    // declare variable
READ #1 "filename.hex" &data      // read data from file to macro
Var.Set \mydata="&data"           // assign content from macro to variable

Note: Macros do only work in PRACTICE script files (*.cmm-files). They do not work in the TRACE32 command line.

Anyhow if you need to parse the data from the file, I would suggest to read-in the complete line from the file to a macro with format option %LINE and then extract the required content from the macro with the STRing-PRACTICE functions like STRing.SPLIT() or STRing.MID() or STRing.SCANAndExtract().

E.g. Get the value from the third column of a CSV file:

PRIVATE &data &value                // declare macros
VAR.NEWGLOBAL char[64] \mydata      // declare variable
READ #1 "filename.csv" %LINE &data  // read one line from file to macro
&value=STRing.TRIM(STRing.SPLIT("&data",",",2))   // get 3rd comma separated value
Var.Set \mydata="&value"            // assign content from macro to variable
Holger
  • 3,920
  • 1
  • 13
  • 35