DO LOOP TAKES TO MOOCH TIME

Dear PML Expert,

Scope of the macro would like to be:

Read two external .txt files, ( tempA.txt ) (tempB.txt )  if thePIPENAME into tempA match with  PIPENAME into tempB

then, I want to associate the OWNER from tempB with PIPENAME from tempA

The loop take to much type and duplicate the row, one whit OWNER and one without.

Appreciate any suggestion? 

thx


******* FIRST STEP COLLECT ALL PIPE AND EXPORT INTO \XXXXX\tempA.txt *************
******* SECOND STEP COLLECT ALL GIPITEM AND EXPORT INTO \XXXXX\tempB.txt *************
FROM GIPITEM EVAL ---> attribute SItem = PIPE NAME
FROM GIPITEM EVAL ---> OWNER = NAME OF COLLECTION

******* THIRD STEP SPLIT INTO ARRAY \XXXXX\tempA.txt *************
!input = |C:\TEMP\PipeReports\tempA.txt|
!INPUTFILE = OBJECT FILE(!INPUT)
!LINES = !INPUTFILE.READFILE()
DO !N INDICES !LINES
!text = !lines[!n].trim()
skip if !text.unset() or !text eq '' or !text.MATCHWILD('*--*') or !text.MATCHWILD('UNIT')

!textA = !text.split(';')
--q var !textA
!!aZ = !textA[1] $* WBS
!!bZ = !textA[2] $* UNIT
!!cZ = !textA[3] $* PURP
!!dZ = !textA[4] $* ZONE
!!pipeB = !textA[5] $* PIPE
!!eZ = !textA $* FLUID
!!fZ = !textA[7] $* DIAM
!!gZ = !textA $* PSPEC
!!hZ = !textA[9] $* STATUS
!!iZ = !textA[10] $* REVISION
!!lZ = !textA[11] $* LOCK
!!mZ = !textA[12] $* DATE MOD
!!nZ = !textA[13] $* USER MOD
--ENDDO


******* FOURTH STEP SPLIT INTO ARRAY \XXXXX\tempB.txt *************
!input = |X:\E3D_ProjectsV3\ANG\ANG\ANGpmllib\design\function\DailyReports\tempB.txt|
!INPUTFILE = OBJECT FILE(!INPUT)
!LINEX = !INPUTFILE.READFILE()
DO !j INDICES !LINEX
!textx = !LINEX[!j].trim()
skip if !textx.unset() or !textx eq '' or !textx.MATCHWILD('*--*')

!textC = !textx.split(';')
!!pipeD = !textC[1].replace('/','')
!!wFM = !textC[2]


******* FIFTH STEP IF NAME OF PIPE ( tempB ) is EQ NAME OF PIPE ( tempA ) *****************
THEN EXPORT ROW WITH NAME OF PIPE ( tempB ) AND OWNER OF ( tempB )


IF !!pipeD eq !!pipeB THEN
--$P YES
VAR !OUTPUTA APPEND '$!!aZ;$!!bZ;$!!cZ;$!!dZ;$!!pipeB;$!!eZ;$!!fZ;$!!gZ;$!!hZ;$!!iZ;$!!lZ;$!!mZ;$!!nZ;$!!wFM'
ELSE
VAR !OUTPUTA APPEND '$!!aZ;$!!bZ;$!!cZ;$!!dZ;$!!eZ;$!!fZ;$!!gZ;$!!hZ;$!!iZ;$!!lZ;$!!mZ;$!!nZ;Null'
ENDIF
ENDDO
ENDDO

********* THIS IF TAKES TO MUCH TIME *********
THE LOOP IS NOT CORRECT ?

  • Hi,

    You read your second file ("TempB.txt") inside your loop.
    You therefore execute the same reading of the same file as many times as you have iterations in your loop.
    You should be able to do this file reading outside your loop, just once, as for your "TempA.txt".

  • Thx Lèo for your suggestion.

    but, I don't have  understand how to put outside the loop.

    Many thx

  • These three lines:

    !input = |X:\E3D_ProjectsV3\ANG\ANG\ANGpmllib\design\function\DailyReports\tempB.txt|
    !INPUTFILE = OBJECT FILE(!INPUT)
    !LINEX = !INPUTFILE.READFILE()

    Can be placed before your first loop, to avoid repeating them:

    --Insert here
    
    DO !N INDICES !LINES

  • Hello Lèo,

    no way...

    the macro working fine only in the first part of codition --->

     IF(!XD EQ !ZB ) THEN, ( if nameOfPipe EQ nameOfSpool ) Then ( append pipe name, pipe attribute and spool attribute )

    on ELSE condition the macro not working fine.

    Should be :

    ELSE 

    ( append pipe name, pipe attribute and spool NoData )

    I don't have understand the error.

    Below the full code.

    Thx a lot for your help

    -----------------------------------------------

    VAR !OUTPUT append 'WBS;UNIT;PURP;ZONE;PIPE;FLUID;DIAM.;PIPE SPEC;STATUS;REVISION;LOCK;DATE MODIFICATION;USER MODIFICATION;SPOOL'



    --------------- STEP 1 COLL GPITEM AND EXPORT IN ESTERNAL TXT
    var !colP COLL ALL GPITEM FOR /FULL-SPOOL
    VAR !GPIT EVAL SItem FOR ALL FROM !colP
    VAR !GOWN EVAL OWNER FOR ALL FROM !colP

    VAR !SORT SORT !GPIT CIASCII !GOWN CIASCII
    DO !i INDICES !SORT
    VAR !OUTPUTB APPEND |$!GPIT[$!i];$!GOWN[$!i]|
    ENDDO

    !file = object file(|C:\TEMP\REPORT\temp1.txt|)
    !file.writefile(|OVER|,!output1)

    !input1 = |C:\TEMP\REPORT\temp1.txt|
    !INPUTFILE1 = OBJECT FILE(!input1)
    !LINE1 = !INPUTFILE1.READFILE()



    --------------- STEP 2 
    VAR !FOR ''
    VAR !FOR 'PIP'
    VAR !pipingSITEs collect ALL PIPE WITH MATCHWILD(PURP OF SITE,'$!FOR')
    VAR !xREF EVAL REFNO FOR ALL FROM !pipingSITEs
    VAR !SORTa SORT !xREF

    --------------- STEP 2A

    DO !i INDICES !SORTa
    !zA = !xREF[$!i]
    --PIPE
    $!zA
    VAR !XA :SP-WBS OF SITE $* WBS
    VAR !XB PURP OF ZONE OF OWNER OF OWNER $* PURP
    VAR !XC NAMN OF ZONE $* ZONE
    VAR !XD NAMN OF PIPE $* PIPE STRING
    VAR !XE BORE
    VAR !XF PSPEC
    VAR !XG :STATUS
    VAR !XH :LASTREV
    VAR !XI LOCK
    VAR !XL LASTMOD
    VAR !XM USERMOD
    VAR !XN substring(namN,1,4) $* UNIT
    VAR !XO substring(namN,7,2) $*FLUID


    --------------- DO OF STEP 1


    DO !j INDICES !LINE1
    !textB = !LINE1[!j].trim()
    skip if !textB.unset() or !textB eq '' or !textB.MATCHWILD('*--*')

    !textC = !textB.split(';')
    !ZB = !textC[1].replace('/','')
    !ZC = !textC[2]


    IF(!XD EQ !ZB ) THEN
    VAR !OUTPUT APPEND '$!XA;$!XN;$!XB;$!XC;$!XD;$!XO;$!XE;$!XF;$!XG;$!XH;$!XI;$!XL;$!XM;$!ZC'
    BREAK
    ELSE
    VAR !OUTPUT APPEND '$!XA;$!XN;$!XB;$!XC;$!XD;$!XO;$!XE;$!XF;$!XG;$!XH;$!XI;$!XL;$!XM;NoData'
    BREAK
    ENDIF

    ENDDO
    ENDDO


    !file = object file(|C:\TEMP\REPORT\ReportPipeSpool.txt|)
    !file.writefile(|OVER|,!output)