Overview by Example: ObxOpen0

This example asks the user for a file, opens the document contained in the file, and appends a string to the text contained in the document. Finally, the text (in its text view) is opened in a window.

	MODULE ObxOpen0;

	IMPORT Files, Converters, Views, Dialog, TextModels, TextMappers, TextViews;

	TYPE
		OpenAction = POINTER TO RECORD (Dialog.GetAction) END;

	PROCEDURE (a: OpenAction) Do;
	VAR v: Views.View; t: TextModels.Model; f: TextMappers.Formatter;
	BEGIN
		IF ~a.cancel THEN
			v := Views.OldView(a.loc, a.name);
			IF (v # NIL) & (v IS TextViews.View) THEN (* make sure it is a text view *)
				t := v(TextViews.View).ThisModel(); (* get the text view's model  *)
				f.ConnectTo(t);
				f.SetPos(t.Length());	(* set the formatter to the end of the text *)
				f.WriteString("appendix");	(* append a string *)
				Views.OpenView(v)	(* open the text view in a window *)
			END
		END
	END Do;
	
	PROCEDURE Do*;
		VAR action: OpenAction;
	BEGIN
		(* ask user for a file and open it as a view *)
		NEW(action);
		Dialog.GetIntLocName("", NIL, action);
	END Do;

END ObxOpen0.

After compilation, you can try out the above example:

  ObxOpen0.Do

With this example, we have seen how the contents of a document's root view can be accessed, and how this view can be opened in a window after its contents have been modified. In contrast to ObxHello1, an existing text has been modified; by first setting the formatter to its end, and then appending some new text.

Note that similar to the previous examples, views play a central role.

In contrast to traditional development systems and frameworks, files, windows, and applications play only a minor role in the BlackBox Component Framework, or have completely disappeared as abstractions of their own. On the other hand, the view has become a pivotal abstraction. It is an essential property of views that they may be nested, to form hierarchical documents.

These aspects of the BlackBox Component Framework constitute a fundamental shift
  from monolithic applications to software components
  from interoperable programs to integrated components
  from automation islands to open environments
  from application-centered design to document-centered design
