AustralianAntarcticDivision / EchoviewR

The R package EchoviewR - a free interface between Echoview and R using COM scripting.
http://australianantarcticdivision.github.io/EchoviewR/
Other
16 stars 9 forks source link

EVGetVariables error #17

Closed hydroacoustic closed 5 months ago

hydroacoustic commented 1 year ago

EchoviewR 1.1.20 function EVGetVariables gives error (Echoview 12 and 13):

Error in EVFile$EVFile[["Variables"]] : object of type 'closure' is not subsettable

hydroacoustic commented 1 year ago

I noticed that the variables are indexed in EchoView not from 1... but from 0...

I have modified the code:

EVGetVariables <- function(EVFile){
  #number of variables in EV FIles
  nvar = EVFile[['Variables']]$Count()
  #create list of variables
  vars = apply(matrix(1:nvar),1,
               FUN=function(x){EVFile[['Variables']]$Item(x-1)$Name()})

  if(length(vars) > 0){
    msgV = paste0(Sys.time(),": Success ", nvar, " variables detected")
  }else{
    msgV = paste0(Sys.time(),": Error - No variables detected")
  }
  message(msgV)

  return(list(variables=vars,msg=msgV))
}

And now it seems to work. For some reason EchoView did not like EVFile$EVFile

raymondben commented 5 months ago

incorporated in https://github.com/AustralianAntarcticDivision/EchoviewR/commit/f56ffe334f05dac768ad197931451882e156dd2e