COMMON behaves similarly to passing variables in a SUBROUTINE command - with the benefit of not being copied back and forth...
For Example: PROGRAM PROGA ZZ = 123 BB = "Hello" CALL PROGB(ZZ,BB) END SUBROUTINE PROGB(VAR1,VAR2) PRINT VAR1 PRINT VAR2 END When that runs, the CALL to PROGB copies the variables from one routine's 'space' into the next, and then on the way back out, copies the changed results back. NAMED COMMON lets those variables persist and live across your LOGIN session ---------------------------------------------- PROGRAM PROGA COMMON \BLOCKA\ BLOCKA1,BLOCKA2,BLOCKA3 COMMON \BLOCKB\ BLOCKB1,BLOCKB2,BLOCKB3 BLOCKA1 = 'Hi' BLOCKB2 = 'There' CALL PROGB CALL PROGC CALL PROGD PRINT BLOCKA1 .... Would now say 'Bye' END ---------------------------------------------- SUBROUTINE PROGB COMMON \BLOCKA\ BLOCKA1,BLOCKA2,BLOCKA3 PRINT BLOCKA1 .... Would print Hi PRINT BLOCKB2 .... Would return an UnInit Var, as that common block was not included in the program RETURN ---------------------------------------------- SUBROUTINE PROGC *Does NOT include the Common Block BLOCKA1 = 'This is NOT overwriting the common' RETURN ---------------------------------------------- SUBROUTINE PROGD COMMON \BLOCKA\ BLOCKD1,BLOCKD2,BLOCKD3 ... Note rename for varialbles... COMMON \BLOCKB\ BLOCKB1,BLOCKB2,BLOCKB3 PRINT BLOCKD1:' ':BLOCKB2 .... Would print Hi There BLOCKD1 = 'Bye' RETURN ---------------------------------------------- So a named common block of FileHandles is a great way to go... BUT - it IS easier to do COMMON in an include statement, mainly so if you add three items to the common, you just have to recompile, and it ensures each file has the exact same names for the common block items across your whole system - which is NOT required - Common block mapping is POSITIONAL - But I personally find making the names 'constant' will avoid a large number of issues!! DW -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chauhan, Savita Sent: Friday, September 02, 2005 8:07 AM To: [email protected] Subject: RE: [U2] Programs slowing down after many iterations Hi, I read all these emails related to COMMON. I am not too old into the U2 world. It seems like an interesting thing that I should be doing in my programs too. Can someone give me a COMMON-101 or direct me to some manual/document which has basic information about 'common'? Thanks, Savita Chauhan IT SW Process Coord Central Texas College (254)526-1754 ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/
