Você está na página 1de 3

10/30/2018 AVEVA. PML BASICS.

Read file | 3D Software Customization

3D Software Customization

ADMIN, PDMS, PML, TUTORIAL

AVEVA. PML BASICS.Read file

JUNE 1, 2017 | ME_HUNGRY | LEAVE A COMMENT


Today I will briefly explain the basic principles of working with file, using PML code.

The main tasks for PML Developers, when they work with files are:
-Process directories and filter certain file extensions
-Open and read file(line by line or fully)
-Search through file and process data
-Add info to file or overwrite its content

Here are some techniques for working with files.

Open certain files with name ‘text.txt’, read line by line to Pdms console window and output line content, if line content matches
string:

Method 1 (For files with lines number less then 10 000)


https://mehungryblog.wordpress.com/2017/06/01/aveva-pml-basics-read-file/ 1/3
10/30/2018 AVEVA. PML BASICS.Read file | 3D Software Customization

–create string variable with file path


!fileName = ‘C:\test.txt’
–create object variable of type FILE
!fileObj = OBJECT FILE(!fileName)
–create array variable and fill all content of that file into it using method ReadFile
!fileContent = !fileObj.Readfile()
–Loop through the array of file content using line numbers variable !x
do !x from 1 to !fileContent.Size()
–Check line content for matching of criteria, should contain ‘*Valve*’
if (!fileContent[!x].Matchwild(‘*Valve*’)) then
–if matches print line content in Pdms\E3D command line
$P Line number is $!x and the value is $!fileContent[$!x]
endif
enddo

Method 2 (for files with line number greater then 10 000)

–create string variable with file path


!fileName = ‘C:\test.txt’
–create object variable of type FILE
!oFileName= OBJECT FILE(!fileName)
–Open file for read
!oFileName.Open(‘READ’)
–Loop through the lines of file
do !recordInd
–Save the value of line
!line = !oFileName.readRecord()
–Check if it is exists, if not stop reading
if !line.set() then
–Check line content for matching of criteria, should contain ‘*Valve*’
if(!line.Matchwild(‘*Valve*’))then
–if matches print line content in Pdms\E3D command line
$P Line number is $!recordInd and the value is $!line
endif
else
break
endif
https://mehungryblog.wordpress.com/2017/06/01/aveva-pml-basics-read-file/ 2/3
10/30/2018 AVEVA. PML BASICS.Read file | 3D Software Customization

enddo
–Close file
!oFileName.Close()

Read more : pmlinpdms (h p://pmlinpdms.blogspot.com)

Advertisements

REPORT THIS AD

REPORT THIS AD
This site uses Akismet to reduce spam. Learn how your comment data is processed.

https://mehungryblog.wordpress.com/2017/06/01/aveva-pml-basics-read-file/ 3/3

Você também pode gostar