APPX is the Premier Development and Runtime Environment for Business Application Software
(Answer) (Category) FAQ's - APPX Software, Inc. : (Category) APPX Utility : (Category) APPX Development Environment : (Category) Tips & Techniques :
Scope of cached files!
When you create a cached version of a file, the contents are treated as a temporary detached memory file. You still have to choose whether each stream is attached to the cache file or the base file (see the topic, “What is the difference between file content and file stream?”).

You create the cache once, but you use OPEN-CACHE?=Y to control each stream. You can switch a given stream back and forth between the cached and base files by executing OPEN statements.

When Appx creates a file stream, it uses the base. If you have file A open in a process, and then invoke a subprocess child, we don't open file A again (and we don't create a new stream). The child shares the parent's stream. You can prove that to yourself by putting a TRAP in the File-level Open event point for file A - it won't get hit when you invoke the child process.

In the case of cached files, the file contents are always created in the first stack frame (i.e. the cached file contents are detached). The file stream always has a subprocess scope.

Here's a test scenario to illustrate how this works. I defined a simple permanent index file with two fields, TESTSCOP NUMBER and TESTSCOP NAME. Then I created a simple scrolling input process (TESTSCOP as the PDF) and entered five test records. I painted --- CHILD ID on the header frame to make it easier to see which input process was running. Next, I wrote a job that invoked the input process six times:

      CHILD ID  Invocation Type  Pre-invocation Open?   
      --------  ---------------- --------------------   
      1ST       Subprocess       No                     
      2ND       Subprocess       Yes - open cached      
      3RD       Subprocess       No                     
      4TH       Related          No                     
      5TH       Subprocess       No                     
      6TH       Subprocess       Yes - open base        
Here are the steps and results:

When the job runs, the first child displays data in the base file (PDF).

In the pre-invocation event point of the 2ND child, I CREATE the cache (type = LOAD), then OPEN the cache, then looped thru each record and appended the word CACHED to each name field. So now the base file is unchanged, but the cache file has the word CACHED in every record. When the 2ND child process runs, it displays the cached file.

When the 3RD child runs, I see the cached records because the stream is shared between the parent and children 2 and 3 (and 5 and 6).

The 4TH child is invoked related. Stream objects are not shared with related invocations, so the base PDF records are displayed.

The 5TH child is invoked subprocess and is identical to the 3RD. I added this child to illustrate that the file contents are persistent. The 5TH child shows the cached records.

In the pre-invocation event point of the 6TH child, I OPEN the CUST file, this time with CACHE set to NONE. The 6TH child displays the base records, as expected.

[Append to This Answer]
2004-Jan-15 5:41am
Previous: (Answer) How do I keep production applications from accidentally being changed?
Next: (Answer) How data sharing is accomplished in APPX!
This document is: http://board.appx.com/cgi-bin/fom.cgi?file=202
[Search] [Appearance]
This is a Faq-O-Matic 2.719.
Copyright 2003 by APPX Software, Inc. All rights reserved.