Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-12-2013, 12:35 AM
aslamyahya aslamyahya is offline Replacing texts Windows 7 64bit Replacing texts Office 2010 64bit
Novice
Replacing texts
 
Join Date: Feb 2013
Posts: 1
aslamyahya is on a distinguished road
Default Replacing texts

The problem is this,

I have this calculation script that i have to use for around 100 times


Code:
CALCU BLOCK 1 One-of-three median transmitter selection
* P01 MODE MEMORY
* P02 AUT/MAN Selection 0=AUT/*=MAN
* P03 Tracking Enable (1=rate limit,*=track)
* P04 Rate Limit (units/min)
* P05 Tx Selection memory
* P06 Tx1 ENABLE
* P07 Tx2 ENABLE
* P08 Tx3 ENABLE
* The AUT/MAN selection is used as a guard to the Tx selection
* done via the faceplate display. P02 must be selected to MAN
* to enable manual selection.
* If AUT mode is used, P01 tracks the calc median Tx to effect
* a bumpless transfer to MAN mode. - the Tx selected in AUT
* remains selected in MAN until changed via the faceplate display.
 
*** The calculated CPV1 in BBBBB is transferred to NEW except
*** in cases when the previous good value has to be retained.
IF((AAAAA.P04 == 3) OR ((AAAAA.CPV == 3) AND (P02 == 0)) OR(P02==1 AND P06+P07+P08==0) ) THEN
    NEW = CPV
    P02 = 1
ELSE
    NEW = BBBBB.CPV1
END IF
*** When mode is switched from auto to manual all transmitters are selected
*** except when all Tx are deviated from one another.
IF(P04==0) P04 = (FINALXMTR.SH - FINALXMTR.SL)
* Check if to apply rate limit - Tx Selection changed
if ( P06+P07+P08 <> P05) P03 = 1
* Calculate current dCPV rate in units/min
Z = (NEW - CPV)*60
* Apply rate limit to output
if ((dabs(Z) >= P04) and (P03==1)) THEN
    CPV=CPV+((1-2*(NEW < CPV)) * P04/60)
else
    CPV = NEW
    P03 = 0
end if
* Enabling Tx1, Tx2 and Tx3 based on healthy state and deviation in the transmitters
P06 = ((P02 == 0 AND (BBBBB.P07 == 1 OR BBBBB.P07 == 4 OR BBBBB.P07 == 6)) OR (P02 ==1 AND P06 == 1 AND AAAAA.P01==0 )) + 0
P07 = ((P02 == 0 AND (BBBBB.P07 == 2 OR BBBBB.P07 == 4 OR BBBBB.P07 == 5)) OR (P02 ==1 AND P07 == 1 AND AAAAA.P02==0 )) + 0
P08 = ((P02 == 0 AND (BBBBB.P07 == 3 OR BBBBB.P07 == 5 OR BBBBB.P07 == 6)) OR (P02 ==1 AND P08 == 1 AND AAAAA.P03==0 )) + 0
* Update Tx selection memory
P05=P06+P07+P08
P1B331INTL10.PV = (P05<>0)+0
* Update mode memory
P01 = P02
end
program
* CALCU BLOCK 2 One-of-three median transmitter selection
*** P01 1=TXR1 UNHEALTHY; 0=TXR1 HEALTHY
*** P02 1=TXR2 UNHEALTHY; 0=TXR2 HEALTHY
*** P03 1=TXR3 UNHEALTHY; 0=TXR3 HEALTHY
*** P06 1=TXR1 AND TXR2 DEVIATION > 5
*** P07 1=TXR2 AND TXR3 DEVIATION > 5
*** P08 1=TXR1 AND TXR3 DEVIATION > 5
*** ALIAS SH FINALXMTR.SH
*** Set the Fail Flag (P01 - P03) according to the Transmitter Status
P01 = ({TRANSMTR1.PV=BAD} OR ({TRANSMTR1.PV=QST} AND NOT {TRANSMTR1.PV=CAL}))
P02 = ({TRANSMTR2.PV=BAD} OR ({TRANSMTR2.PV=QST} AND NOT {TRANSMTR2.PV=CAL}))
P03 = ({TRANSMTR3.PV=BAD} OR ({TRANSMTR3.PV=QST} AND NOT {TRANSMTR3.PV=CAL}))
*** Finding Deviation in Txrs
ab = TRANSMTR1.PV-TRANSMTR2.PV
ac = TRANSMTR1.PV-TRANSMTR3.PV
bc = TRANSMTR3.PV-TRANSMTR2.PV
*** Finding Deviation Values
P06 = (dabs(ab) > (5*FINALXMTR.SH/100)) ! Deviation between TXR1 and TXR2 > 5 % of Scale-High value
P07 = (dabs(bc) > (5*FINALXMTR.SH/100)) ! Deviation between TXR2 and TXR3 > 5 % of Scale-High value
P08 = (dabs(ac) > (5*FINALXMTR.SH/100)) ! Deviation between TXR1 and TXR3 > 5 % of Scale-High value
CPV1 = (P06) AND (P08) ! Deviation in TXR1 w.r.t. TXR2 and TXR3
CPV2 = (P06) AND (P07) ! Deviation in TXR2 w.r.t. TXR1 and TXR3
CPV3 = (P07) AND (P08) ! Deviation in TXR3 w.r.t. TXR1 and TXR2
P04 = P01 +P02 +P03
CPV = CPV1+CPV2+CPV3
P1LAD80CL001XC03.PV = CPV1
P1LAD80CL002XC03.PV = CPV2
P1LAD80CL003XC03.PV = CPV3
P1LAD80CL901XC03.PV = (CPV == 3) + 0
P1B331SSM10.SW = 2*(P04==3) + 1*(P04<3)
P1B331INT01.PV = 1*((P04>=2) OR (P04==1 AND (NOT P01*NOT P02* P06 + NOT P02*NOT P03* P07 + NOT P02*NOT P03* P07 == 2)) OR CPV>=2 )
end
program
* CALCU BLOCK 3 One-of-three median transmitter selection
*** P01 Median Value
*** P02 Average of Tx1 and Tx2
*** P03 Average of Tx1 and Tx3
*** P04 Average of Tx2 and Tx3
*** P07 Tx Selection buffer
*** P08 Dummy Variable for finding Tx sel
P01 = ( TRANSMTR1.PV + TRANSMTR2.PV + TRANSMTR3.PV - dmin(TRANSMTR1.PV,TRANSMTR2.PV,TRANSMTR3.PV) - dmax(TRANSMTR1.PV,TRANSMTR2.PV,TRANSMTR3.PV) )
P02 = ( TRANSMTR1.PV + TRANSMTR2.PV )/2
P03 = ( TRANSMTR1.PV + TRANSMTR3.PV )/2
P04 = ( TRANSMTR3.PV + TRANSMTR2.PV )/2
*** Auto Mode Operation
*** P07 Buffer is used to update Tx enabling in calcu block 1.
IF(CCCCC.P02==0) THEN
    *** Thre Transmitters are Healthy. Based on Deviation in the Txs, Median or Average or Individual Tx value is selected.
    IF(AAAAA.P04==0) THEN
        CPV1 = (AAAAA.CPV==0)*P01 + (AAAAA.CPV==1)*((P02*AAAAA.CPV3) + (P03*AAAAA.CPV2) + (P04*AAAAA.CPV1)) +(AAAAA.CPV>=2)*CCCCC.CPV
        P08 = (AAAAA.CPV==0)*1 + (AAAAA.CPV==1)*2 + (AAAAA.CPV>=2)*0
        P07 = (P08==1)*(1*(CPV1==TRANSMTR1.PV)*(CPV1<>TRANSMTR2. PV)*(CPV1<>TRANSMTR3.PV)+2*(CPV1==TRANSMTR2.PV)*(C PV1<>TRANSMTR3.PV)+3*(CPV1==TRANSMTR3.PV))+(P08==2 )*(4*(CPV1==P02)+5*(CPV1==P04)+6*(CPV1==P03))
        *** Two Transmitters are Healthy(With/ Without Deviation in the Healthy Transmitter)
        *** If healthy, average is selected. Else, selection becomes Manual and is in the scope of the operator to make a selection.
    ELSE IF(AAAAA.P04 == 1) THEN
        IF((NOT AAAAA.CPV1 * NOT AAAAA.P01) + (NOT AAAAA.CPV2* NOT AAAAA.P02) + (NOT AAAAA.CPV3 * NOT AAAAA.P03) ==2) THEN
            CPV1 = ( P02*(NOT AAAAA.P01 * NOT AAAAA.P02 * NOT AAAAA.P06 ) + P04*(NOT AAAAA.P02 * NOT AAAAA.P03 * NOT AAAAA.P07) + P03*(NOT AAAAA.P01 * NOT AAAAA.P03* NOT AAAAA.P08) )
            P08 = 1*(AAAAA.P01==1) + 2*(AAAAA.P02==1) + 3*(AAAAA.P03==1)
            P07 = 5*(P08==1) + 6*(P08==2) + 4*(P08==3) + 0
        ELSE IF(NOT AAAAA.P01 * NOT AAAAA.P02 * AAAAA.P06 * AAAAA.P03 + NOT AAAAA.P01 * NOT AAAAA.P03 * AAAAA.P08* AAAAA.P02 + NOT AAAAA.P03 * NOT AAAAA.P02 * AAAAA.P07 * AAAAA.P01) THEN
            CPV1 = CCCCC.CPV
            CCCCC.P02 = 1
        END IF
        *** One Transmitter is only Healthy, then the corresponding Tx is selected
    ELSE IF(AAAAA.P04==2) THEN
        CPV1 = TRANSMTR1.PV*NOT AAAAA.P01 + TRANSMTR2.PV*NOT AAAAA.P02 + TRANSMTR3.PV*NOT AAAAA.P03
        P07 = 1*(AAAAA.P01==0)+ 2*(AAAAA.P02==0)+3*(AAAAA.P03==0) + 0
    END IF
END IF
END
program
* CALCU BLOCK 4 One-of-three median transmitter selection
 
*** P01 Buffer flag for disabling Auto mode in Custom FacePlate
*** P05 Tx selection from faceplate
*** Manual Mode Operation
*** Operator selection via Faceplate taking into account the deviation between Txs
*** A Tx cannot be selected if it has a deviation with a Tx that is selected
if(CCCCC.P02==1) then
    IF(CCCCC.P01==CCCCC.P02 AND P05==1) THEN
        Y = ((CCCCC.P06-(P05==1)) AND NOT AAAAA.P01 )
        CCCCC.P06 = dabs(Y) * NOT((CCCCC.P07 * NOT(AAAAA.P02) * AAAAA.P06) OR (CCCCC.P08 * NOT(AAAAA.P03) * AAAAA.P08)) * NOT AAAAA.P01
    ELSE IF (CCCCC.P01==CCCCC.P02 AND P05==2) THEN
        Z = ((CCCCC.P07-(P05==2)) AND NOT AAAAA.P02 )
        CCCCC.P07 = dabs(Z) * NOT((CCCCC.P06 * NOT(AAAAA.P01) * AAAAA.P06) OR (CCCCC.P08 * NOT(AAAAA.P03) * AAAAA.P07)) * NOT AAAAA.P02
    ELSE IF (CCCCC.P01==CCCCC.P02 AND P05==3) THEN
        X = ((CCCCC.P08-(P05==3)) AND NOT AAAAA.P03 )
        CCCCC.P08 = dabs(X) * NOT((CCCCC.P07 * NOT(AAAAA.P02) * AAAAA.P07) OR (CCCCC.P06 * NOT(AAAAA.P01) * AAAAA.P08)) * NOT AAAAA.P03
    END IF
    P05 = 0
    *** Three Transmitters are enabled, Median or Average value is chosen considering the deviation between the selected transmitters.
    IF(CCCCC.P06 + CCCCC.P07 + CCCCC.P08 == 3) THEN
        BBBBB.CPV1 = (AAAAA.CPV==0)*BBBBB.P01 + (AAAAA.CPV==1)*((BBBBB.P02*AAAAA.CPV3) + (BBBBB.P03*AAAAA.CPV2) + (BBBBB.P04*AAAAA.CPV1)) +(AAAAA.CPV>=2)*CCCCC.CPV
    END IF
    *** Two Transmitters are enabled(With/Wothout deviation in the selected Transmitters)
    *** Average is computed if there is no deviation between the two Txs otherwise, previous value is retained.
    IF(CCCCC.P06 + CCCCC.P07 + CCCCC.P08 == 2) THEN
        IF(CCCCC.P06*CCCCC.P07*AAAAA.P06 + CCCCC.P07*CCCCC.P08*AAAAA.P07 + CCCCC.P06*CCCCC.P08*AAAAA.P08 == 0) THEN
            BBBBB.CPV1 =(BBBBB.P02*(CCCCC.P06 * CCCCC.P07 * NOT AAAAA.P06)+BBBBB.P04*(CCCCC.P08 * CCCCC.P07 * NOT AAAAA.P07 )+BBBBB.P03*(CCCCC.P08 * CCCCC.P06 * NOT AAAAA.P08))
        ELSE
            BBBBB.CPV1 = CCCCC.CPV
        END IF
    END IF
    *** One Transmitter enabled, that particular value is selected.
    IF(CCCCC.P06 + CCCCC.P07 + CCCCC.P08 < 2) THEN
        BBBBB.CPV1 = (CCCCC.P06 + CCCCC.P07 + CCCCC.P08 == 1)*(TRANSMTR1.PV*CCCCC.P06 + TRANSMTR2.PV*CCCCC.P07 + TRANSMTR3.PV*CCCCC.P08 )
    END IF
END IF
*** For Custom Face plate use(For disabling the AUTO selection during faulty state)
P01 = 1* ((AAAAA.P01+AAAAA.P02+AAAAA.P03==1) AND (NOT AAAAA.P01 * NOT AAAAA.P02 * AAAAA.P06 + NOT AAAAA.P01 * NOT AAAAA.P03 * AAAAA.P08 + NOT AAAAA.P03 * NOT AAAAA.P02 * AAAAA.P07) ) + 0
end
I have values AAAAA, BBBBB, CCCCC, TRANSMTR1, TRANSMTR2, TRANSMTR3 and FINALXMTR in another sheet.

Can anyone help me with some macro that would enable me to do this.



Thanks a lot in advance

Last edited by macropod; 02-27-2013 at 11:23 PM. Reason: Added code tags & formatting
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Clickable Links Converted to hyperlink texts automatically when I open a word doc Kingsly Word 2 09-13-2012 10:42 AM
Replacing texts change color of critical activity texts ketanco Project 3 01-05-2012 06:36 PM
Replacing texts Replacing default fonts mark98101 Word 1 01-31-2011 02:31 PM
word changes settings while copiing texts marja Word 2 11-29-2010 01:17 PM
Replacing / editting text LisaC Word 0 02-25-2010 03:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:50 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft