[M3devel] finding a file

Randy Coleburn rcoleburn at scires.com
Thu Nov 12 03:47:16 CET 2009


Hendrik:
 
Here is an excerpt from the FormsVBT Reference Manual (page 14) that
describes how to choose at runtime whether to use the bundled data or
data stored in a file.  Hope this helps.
 
Regards,
Randy
 
MODULE Hello EXPORTS Main;
IMPORT FormsVBT, HelloBundle, Rsrc, Trestle;
VAR
   path := Rsrc.BuildPath(HelloBundle.Get());
   fv := NEW (FormsVBT.T).initFromRsrc ("Hello.fv", path);
BEGIN
   Trestle.Install(fv);
   Trestle.AwaitDelete(fv)
END Hello.

The call to HelloBundle.Get returns a bundle that is used to create a
resource-path, which is
then searched by the initFromRsrc method.
But what if you want the application to use new resource files? For
example, you might have
changed some details of the .fv file that don*t require any changes to
the application code. Do you
have to rebuild the entire application?
Fortunately, the answer is no. However, you do need to tell FormsVBT
that youwant it to look for
those resources in the file systembefore it looks for them among the
resources that were bundled into
the application. You do this by changing the resource-path so that it
includes one ormore directories
before the bundle.
The convention is to use environment variables whose names are spelled
by combining the program*s
name with the string "PATH". This variable should be set to a list of
directory-names, each
separated by a colon. So, if you want to run the Hello program using
the Hello.fv file that*s in
Smith*s home directory instead of the one that*s bundled with the
application, you would type something
like this shell command:
   setenv HelloPATH /user/smith
In the program, you would construct a resource-path that included this
directory by adding the name
HelloPATH, prefixed with a dollar sign:
MODULE Hello EXPORTS Main;
IMPORT FormsVBT, HelloBundle, Rsrc, Trestle;
VAR
   path := Rsrc.BuildPath("$HelloPATH", HelloBundle.Get());
   fv := NEW (FormsVBT.T).initFromRsrc ("Hello.fv", path);
BEGIN
   Trestle.Install(fv);
   Trestle.AwaitDelete(fv)
END Hello.

>>> <hendrik at topoi.pooq.com> 11/10/2009 1:34 PM >>>
On Sat, Nov 07, 2009 at 03:34:12PM -0500, Randy Coleburn wrote:
> Sounds like a job for bundles.
>  
> I use bundles a lot with FormsVBT and Trestle in Modula-3.  The idea

> is that you create a bundle of the file(s) you need, but you code it

> so that you can override these bundled defaults by placing a real
file 
> in a certain location relative to the program binary.
>  
> If you want to see a code example, let me know and I'll send you
something.

Yes, I'd appreciate a code example.

-- hendrik

CONFIDENTIALITY NOTICE:  This email and any attachments are intended
solely for the use of the named recipient(s). This e-mail may contain
confidential and/or proprietary information of Scientific Research
Corporation.  If you are not a named recipient, you are prohibited from
making any use of the information in the email and attachments.  If you
believe you have received this email in error, please notify the sender
immediately and permanently delete the email, any attachments, and all
copies thereof from any drives or storage media and destroy any
printouts of the email or attachments.

EXPORT COMPLIANCE NOTICE:  This email and any attachments may contain
technical data subject to U.S export restrictions under the
International Traffic in Arms Regulations (ITAR) or the Export
Administration Regulations (EAR).  Export or transfer of this technical
data and/or related information to any foreign person(s) or entity(ies),
either within the U.S. or outside of the U.S., may require export
authorization by the appropriate U.S. Government agency prior to export
or transfer.  In addition, technical data may not be exported or
transferred to certain countries or specified designated nationals
identified by U.S. embargo controls without prior export authorization. 
By accepting this email and any attachments, all recipients confirm that
they understand and will comply with all applicable ITAR, EAR and
embargo compliance requirements.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20091111/d7dfaf68/attachment-0002.html>


More information about the M3devel mailing list