Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Engineering

Reading and Writing ARRAYS

  • Last UpdatedOct 24, 2022
  • 1 minute read

You will obtain much quicker performance if you read or write an entire array in a single operation. In particular, you are recommended to use the ReadFile() method which returns the whole file as an array of strings, opening and closing the file automatically:

!Input = object FILE('DATA')

!Output = object FILE('RESULTS')

!Lines = !Input.ReadFile()

!ResultArray = ARRAY()

do !Line VALUES !Lines

 !Numbers = !Line.Split()

 !Total = !Numbers[1].Real() + !Numbers[2].Real()

 !ResultArray.Append( !Total.String() )

enddo

!Output.WriteFile('WRITE', !ResultArray)

Note:
With the ReadFile() method you may optionally specify the maximum number of lines you are prepared to read and an error is raised if this number is exceeded. If not specified, a limit of 10000 is imposed.

TitleResults for “How to create a CRG?”Also Available in