0% found this document useful (0 votes)
241 views

PDMS - Command Syntax

The document discusses two methods for reading files in PML code. The first method reads the entire file into an array if it has less than 10,000 lines. It then loops through the array to check for matching content. The second method opens the file, reads it line by line, and checks for matches without loading the entire file into memory. This is necessary for files with over 10,000 lines. The document provides code examples to demonstrate these two techniques.

Uploaded by

LANKAPALLISURI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
241 views

PDMS - Command Syntax

The document discusses two methods for reading files in PML code. The first method reads the entire file into an array if it has less than 10,000 lines. It then loops through the array to check for matching content. The second method opens the file, reads it line by line, and checks for matches without loading the entire file into memory. This is necessary for files with over 10,000 lines. The document provides code examples to demonstrate these two techniques.

Uploaded by

LANKAPALLISURI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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

You might also like