I am using a gnuplot script that yields an error when the last line of the script is executed. I don't see any issue with this line. The error is: ')' expected. If a move the line array M_x_N[numRecord] before the line
stats N using (M_x_N[int($0+1)] = N[int($0+1)]*M[int($0+1)]) name "M_x_N" nooutput
there is no error. What wrong?
I am using the QT terminal, gnuplot 5.4 patch level 8. OS is Windows 10.
The script is:
reset session
set encoding utf8
set datafile separator comma
cd 'C:\Users\smallz4'
corpusFile = "lz4_silicia_corpus.txt_4096.csv"
stats corpusFile nooutput
numRecord = STATS_records
chunkSize = numRecord-15.0
bias = 2048.0
array M[numRecord]
array N[numRecord]
array M_x_N[numRecord]
stats corpusFile using (M[int($0+1)] = $1) name "M" nooutput
stats corpusFile using (N[int($0+1)] = $2) name "N" nooutput
stats N using (M_x_N[int($0+1)] = N[int($0+1)]*M[int($0+1)]) name "M_x_N" nooutput
Ok, I was struggling a while to find out what's going on. For a reason which I don't yet understand, it seems the name of your final array causes the error.
help variablessays:So,
M_x_Nshould be a valid variable or array name. At least, I haven't yet found a statement that says_is not allowed for array names.With the following minimal, complete example, I can reproduce your error. And now, I think I understand what you mean. Apparently, the sequence of the array definitions and the
statscommands are important.Script: (this script will fail with your error)
However, if you change the sequence to the following, it will work.
Another version with the original sequence, i.e. all array definitions first and then all
statscommands will work as expected, if you change the name of the arrayM_x_NtoMxN.So, my conclusion would be that the underscores in
M_x_Nsomehow mess up thestatscommand. I would consider this a bug or maybe someone else can explain.