On Monday, January 19, 1998, 05:31 AM, prowak wrote: Derek, I'd like to pursue the 2nd of your suggestions. You said that I could use EXPORT/IMPORT. As the application is now, I 'm passing the procedure data from my main line via parameters. And I'm using D-specs to define each of the parms. I am currently not using either EXPORT or IMPORT in my main line or any of the procedures. Am I doing this correctly? I'm still not sure what the problem you are trying to solve is, so I'm not sure if using import/export is an appropriate solution or not, but here's an example that should illustrate the mechanics: DDS for physical file yourFile: *--------------------------------------------------------------------- A R RCD A FIELD1 30A A FIELD2 7P 0 *---------------------------------------------------------------------
Your mainline program: *--------------------------------------------------------------------- FyourFile IF E DISK D DoSomething PR EXTPROC('MBR2') D SharedStruc1 E DS EXTNAME(yourFile) IMPORT D SharedField1 S LIKE(Field1) IMPORT C READ yourFile 99 C EVAL SharedField1 = 'Hello' C C CALLP DoSomething C C EVAL *INLR = *ON C RETURN *--------------------------------------------------------------------- This is the procedure in your service program (called MBR2): *--------------------------------------------------------------------- D SharedStruc1 E DS EXTNAME(yourFile) EXPORT D SharedField1 S LIKE(Field1) EXPORT C SharedField1 DSPLY C Field2 DSPLY Reply 1 C C RETURN *---------------------------------------------------------------------
When you run this it duly displays "hello" and the value from Field2 found in the record read by your mainline pgm. Things to note: [*]It doesnt appear that you can do this the other way round (ie. import into your *srvpgm from a *pgm object).[*]The srvpgm procedure with the export keyword must have the entry point code ie. you cant export from within a subprocedure.[*]If you have multiple pgms importing, say SharedField1, they are using the same piece of storage. This means a change by pgm1 will be seen by pgm2, so be careful how you use this.[/list]I am very much of the same view as Joe regarding using global variables. One of the best techniques I know for producing reliable, maintainable code, is to limit the scope of data (variables) to the minimum necessary for the task. Global data is to software is what *allobj is to security. Sure its easier to just give everyone *allobj, but it's rarely a good idea.... Derek