General:File Contexts define
where physical files exist. In simple environments this is just the path (e.g.
c:\glee\). The use of File Contexts allows separation of the file
usage from its physical location. For example, you could create a whole system
based on a File Context of "c:\glee\test". When ready for
production, you could change the FileContext to
"c:\glee\production" and all activity would relate to files
in that path. Further, as distributed systems become supported, the File
Context could become something like
"WithGLEE.com::\glee\master\". Note: File Contexts always
end with "\" so they are easily distinguished from
files which do not end with "\".
Set Current Working Directory
(CWD): File Contexts may be relative (specifiy only a portion of the path)
or absolute (specify the complete path). If they are relative, they relate to
the Current Working Directory (CWD). You can set the system's CWD by assigning
to the #FC operator. The effect is to change the target of all
existing relative File Contexts. The absolute File Contexts are unaffected. If
you attempt to set an invalid CWD, a diagnostic is issued and no change is
made.
Niladic #FC: Creates a File
Context object with no relative or absolute path. Thus, these File Contexts are
relative to the CWD. Note: The Current Working Directory is initially the
directory containing GLEE.exe. (e.g. "c:\glee\").
Monadic #FC: Creates a File
Context object having the path given in the left argument. The path need not be
valid. It may be relative or absolute.
Assignment to #FC (Change
Current Working Directory (CWD)): When you change the current working
directory, all File Contexts with relative paths are affected (at run time).
This also affects where scripts are saved by this Test Stand. File Contexts
with absolute paths are not affected. This example gets a little ahead of
itself by illustrating catenation of File Contexts (glee,ws .path $;
). It is probably better to form absolute paths by catenation as in the example
than by changing the CWD. Changing the CWD affects where the Glee scripts are
stored. Forming paths by catenation does not affect the CWD and thus does not
affect storing of scripts in this test stand.
Assigning to an existing File
Context: You can assign to the .fc property of an existing file
context and change its target.
Catenate ( , ): You
can catenate FCs to make up a path. The right argument cannot be an absolute
FC.
Relative Name Part Monadic(
-> ): A File Context may be considered to be made up of a name
part and a path part. Both may be empty. They are implicitly defined. The name
part is the portion of the path from the end forward to the second slash (
\ ). The monadic form of the take returns a File Context of just the
name part.
Relative Name Part Dyadic (
-> n ): The dyadic form does a take (or drop) considering the
path and name parts together. Take (positive n) takes segments from the right
end of the path and name combination. Drop (negative n) drops segments from the
front of the path and name combination.
Relative Path Part Monadic (
<- ): This returns a File Context of the first segment of the
path part. It is the same as the dyadic form with a positive 1 argument.
Relative Path Part Dyadic (
<- n ): With n of +1, this behaves just like the monadic form.
For n > +1, segments are taken from the right side of just the path part.
The name part is ignored. If n is negative, segments are dropped from the
beginning of just the path part. A file context is return for the resulting
segments of the path.
Absolute Name Part Monadic(
->> ): The absolute form considers the Current Working
Directory (CWD) when forming the path part. Otherwise if behaves exactly like
the relative forms described above.
Absolute Name Part Dyadic (
->> n): The absolute form considers the Current Working
Directory (CWD) when forming the path part. Otherwise if behaves exactly like
the relative forms described above.
Absolute Path Part Monadic(
<<- ): The absolute form considers the Current Working
Directory (CWD) when forming the path part. Otherwise if behaves exactly like
the relative forms described above.
Absolute Path Part Dyadic (
<<- n): The absolute form considers the Current Working
Directory (CWD) when forming the path part. Otherwise if behaves exactly like
the relative forms described above.