i21sys/Docu/Desktop.odc

i21sysDesktop
Derived by Fyodor Tkachov (ftkachov@inr.ac.ru) from an earlier PrivDesktop by Bruno Essmann (bessmann@iiic.ethz.ch), Guy Laden (laden@math.tau.ac.il), Iain Scott (iain.i.scott@gecm.com); see also the package Desktop at http://www.zinnamturm.eu.
This module contains dependencies on undocumented modules Windows and Documents, and a few calls to WinApi, HostFiles, and HostWindows. It was developed on the BlackBox version 1.5 with modifications to handle Cyrillic characters as distributed from http://www.inr.ac.ru/~info21/software.htm.
This document incorporates only minimal information from the updated Russian document (Docu/ru/Desktop).

DEFINITION i21sysDesktop;
	IMPORT Files;
	VAR
		saveName-: Files.Name;
		savePath-: ARRAY 2000 OF CHAR;
	PROCEDURE Close;
	PROCEDURE Exit;
	PROCEDURE Open;
	PROCEDURE Restore;
	PROCEDURE RestoreFrom (name: ARRAY OF CHAR);
	PROCEDURE Save;
	PROCEDURE SaveAs;
END i21sysDesktop.

This tool supports saving and restoring the arrangement of windows within BlackBox.

Purpose 
This version is an attempt to simpify and clarify the original, and to ensure that the original ordering of windows is restored exactly.
The primary target audience was the 11-year old schoolkids learning to program with BlackBox (the project Informatika-21 at http://www.inr.ac.ru/~info21/). Their operations served as "use cases" to augment the author's personal experience with the somewhat overcomplicated original version. 

Usage 
The usage is straightforward: 
The command Exit saves the current state of windows open within BlackBox to a file and terminates BlackBox.
The command Restore restores the saved state. 
The command Save saves the desktop without exiting BlackBox.
.......
By default, the desktop state is saved to, and restored from, the file desktop.i21 in the working directory. This is controlled by the two global variables saveName and savePath.
Conservatively, one would add the following two commands e.g. to the System menu in the Window section: 
	"Save Desktop"	""	"i21sysDesktop.Save"	""
	"Restore Desktop"	""	"i21sysDesktop.Restore"	""
One could also modify the item Exit in the File section of the System menu, as follows:
	"E&xit"	""	"i21sysDesktop.Exit"	""
A bit riskier proposition is to include the following call at the end of the procedure Config.Setup:
	Dialog.Call("i21sysDesktop.Restore", "", res);
Should there be any problems with loading the desktop, delete or rename desktop.i21.


This tool works particularly well when running BlackBox in the server mode, and using various project folders as working directories (indicated after the /Use command line parameter). To facilitate this, prepare a vbs script (a text file with extension *.vbs) that contains the following lines (remember to change the prg value according to your BlackBox installation): 

' Original author: Bernhard Treutwein BdT(at)wildwein de
' Adapted by Fyodor Tkachov ftkachov(at)inr.ac.ru
Option Explicit
Dim prg
prg = """u:\BlackBox\BlackBox.exe"""  ' full path name of your BlackBox installation
Dim sh
Set sh = WScript.CreateObject("WScript.Shell")
sh.Run prg & " " & "/use """ & sh.CurrentDirectory & """", 1, false
' The multiple double quotes ensure a correct handling of paths with spaces etc.
' Copy the script to any folder and run it; BlackBox then starts 
' in the server mode with this folder as working folder.

This way of using BlackBox may be useful when more than one BlackBox configuration are used.