Oberon/F Views and Files 
Author Message
 Oberon/F Views and Files


Quote:
> Oberon/F 1.1 Beta for Win... Look at Oberon by Example: ObxOpen0

> PROCEDURE Do*;
>    VAR loc: Files.Locator; name: Files.Name; conv: Converters.Converter;
>      v: Views.View; t: TextModels.Model; f: TextMappers.Formatter;
>    BEGIN
>      loc := NIL; name := ""; conv := NIL;
>      v := Views.Old(Views.ask, loc, name, conv);

> What other values can loc have? How do you set it? The same goes for conv...

See documentation of modules Files and Converters.
The locator is the path to the file, and the converter specifies how the file
has to be converted into Oberon/F format. If you call Views.Old(Views.ask,
loc, name, conv), then these specific parameters are set through the Open
dialog box. Currently converters are available for ASCII files and ETH-Oberon
V4 text files, i.e. Oberon-V4 texts can directly be opened in Oberon/F
without loosing the formatting and style informations. Other converters could
be written e.g. for the System3 format as well as for HTML or RTF formats.

Quote:
> Suppose I wanted to get to a specific file in a specific directory
> (i.e. say \oberonf\usrdata\user.txt ) which is stored in ASCII format. How
> would I do this? Which of these things needs to be set if I chose to use
> the Views.dontAsk option?

All parameters have to be set if you use Views.dontAsk. You have to specify
the path and the name of the file as well as which converter has to be used.
If the file to be opened is already in the Oberon/F format, then you can pass
NIL as converter.

To set the locator to \oberonf\userdata call loc :=
Files.dir.This("\oberonf\userdata"). You may also use "/" to separate
directories on the path in a portable way. Files.dir.This("") returns the
default path, normally the path to the OberonF home directory. With loc.This
you can then set the path relative to loc.

If you have to pick up a particular converter, then you have to search
through  the list of registered converters and to look for what you are
looking for. You might look for the normal ASCII converter
TextConv.ImportText or any other ASCII converter (as e.g. a HTML converter or
a TeX converter or whatever). In the example below I look for the first
converter which understands the same file type as the file (loc, name).

   PROCEDURE Do*;
      VAR loc: Files.Locator; name: Files.Name; c: Converters.Converter;
        f: Files.File; v:Views.View;
   BEGIN
      COPY("Test0", name); (* the file name *)
      loc := Files.dir.This(""); (* default location *)
      f := Files.dir.Old(loc, name, Files.shared); ASSERT(f # NIL, 21);
      c := Converters.list;
      WHILE (c # NIL) & (c.fileType # f.type) DO c := c.next END;
      ASSERT(c # NIL, 22);
      v := Views.Old(Views.dontAsk, loc, name, c);
      Views.Open(v, loc, name, c)
      (* if the file should be stored in the OberonF format, then  NIL has to
      be passed as converter  in the Views.Open command, otherwise the file is
      converted back to its original format. *)
   END Do;

However this is a rather rare situation you are describing here. Normally
the files are stored in the Oberon/F format and can be opened directly with
the command                    

        v := Views.OldView(loc, name");

without having to specify a converter.

- Dominik Gruntz
  Oberon microsystems, Inc.



Thu, 29 Jan 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Oberon/F Views and Files

2. Viewing (or *not* viewing) .wrl files with NS3.0b5

3. Load .wrl Files, View it, centered in View

4. Oberon/F newbie question about views

5. Scrolling views in Oberon/F

6. Oberon/F needs a form subsystem for views

7. Oberon/F: Link self-written views?

8. Oberon/F: linking views, scripting?

9. Oberon/F: extending TextViews.View ?

10. File I/O Operations on Secondary VIEW(ed) Files

11. Using files from Robolab pilot as seed files for inventor level or lab view

12. .WRL files viewed as ZIP files

 

 
Powered by phpBB® Forum Software