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