@ MOS System and Context
: System Directory
^The MOS System Directory

 System directory :
 This directory is one vital elements of MOS, it contains a series of
 necessary files for the good functioning of MOS software.

 You must absolutely have in this directory 3 files ".LOC" of language
 definition (English, French and Spanish).

 Palette files of extension ".PAL" are necessary for the good functioning of
 the "Palette" requester, they contain the different palettes proposed to the
 user by the intermediary of the palette menu.

: Initialisation
^Initialisations Files (.INI)

 Introduction :
 When one to create a software, it is often interesting to power create,
 publish and use a file of configuration for this software (File ".INI").
 MOS allows this functionality. You define the configuration of the interface
 of your software with the requester "SYSTEM_REQUEST", that allows then to
 safeguard automatically the configuration defined under a name of file that
 you desire.

 Definition of the name of file :
 There is two case in function of the name that you give for the file of
 safeguard:

 - If the name of safeguard is "MOS.INI" or well the name of your runable
 program followed by the extension ".INI", each time that you will launch
 a program "MOS", the system will load this file, and will use its parameters,
 to the manner whose "Windows" uses the "WIN.INI".

 - If the name of safeguard is different the two preceding name, the file
 safeguarded will not be automatically loaded by the system to the launching
 of a software "MOS", you will have then to load it you even with the
 procedure LOAD_CONFIG in specifying the name and path of the file.
 You can thus define your clean file of configuration for your  software in
 addition of the normal configuration of MOS.
 Once the loaded file, most of system variables are reinitialised
 Suitable exception of the change of mode, or the automatic redisplaying of  
 the screen in case of change of character style.

 You can thus safeguard and use the configuration of MOS, or one of your
 software to will without being obliged to program this function.

 Principle of functioning :
 To the each software launching, MOS is going to look if it can find in the
 directory running a file of configuration of the name of "PROG.INI" where
 "PROG" is the name of the program launched. In the case or it would not find
 this file, it is going to try to find and to use a "MOS.INI", if these two
 files are not found, MOS is going to research in each directory of the Path
 if there exists a file "MOS.INI", to which case, it will use it. If no file
 of configuration is found, MOS will initial with parameters by defect.

 If you desire to have a particular configuration for all software MOS that
 you will create, safeguard this configuration under the name of "MOS.INI"
 in the directory running, or better, in the directory or you have installed
 MOS, because have directory has normally to be found in the Path.

 Advantages of the ".INI" :
 Besides the great suppleness of software utilization MOS thanks to files of
 configurations, the ".INI" allow especially specify the place where MOS has
 to be going to seek its system files, what allows them not to have in the
 directory running, where an evident place gain. With an alone directory
 containing all files whose MOS needs to function, and each ".INI" pointing
 on this directory, MOS orients henceforth to an architecture of interface
 structured.

 The disadvantage of this process, is that if you desire to copy a software
 MOS on an other hard disk that it your, and that this hard disk have not the
 system MOS installed, it will be necessary to copy with the entire content
 of the system directory, or in any case , vital files of the directory whose
 MOS to absolutely need to function, that is to say, file whose suffix is "
 .LOC".

 Selection of a ".INI" by line of order :
 You can specify the utilization of a ".INI" other that that that has
 normally to be used by passing in the line of orders the parameter
 "-INI=File" where "File" is the path and the name of the new file of
 initialisation.
 Example: PROG.EXE -INI=C:\TOOLS\PROG2.INI

 Usable procedures :

 ~SAVE_CONFIG~             Safeguards the configuration of the system
 ~LOAD_CONFIG~             Tends and initials the configuration of the system
 ~SYSTEM_REQUEST~          Allows to define the configuration of the system

 Postpone - you to the paragraph "Utilization of the main functions of MOS"
 and "Utilization of the requester of MOS" of the graphic interface for the
 detailed description of these functions and procedures.

 Languages and .INI
 You can modify comments of the .INI by modifying the .LOC (Cf. Location
 chapter of the interface). It suffices indeed to publish Text files .LOC and
 to modify stamps of file comments .INI.

 NB: You can modify manually the ".INI" by editing it. It is elsewhere what
 you will be able to be brought to make in the case or MOS would not launch
 because of an erroneous parameter in the file of configuration ".INI".

: Localisation Files 
^Localisation Files (Languages)

 Introduction :
 MOS since its version 2.0 possesses a very interesting ability, that is to
 power use the language that you desire to operate the interface.
 You have the choice between three different languages :
	English, Fran‡ais, Espanol.

 When a language is selected, all the requester, switchboard masks, and
 messages of the system MOS are displayed in this language. In the case or
 no language is selected, or that the asked language does not exist, MOS uses
 automatically in the English language.

 Principle :
 To select a language, open the requester "System", and click on the button
 "LOCALE". You are then proposed three languages symbolized by small flags.
 Select that your choice. The interface passes immediately in the language
 selected.

 You have you also the possibility to change to your sandstone the language
 of the interface, thanks to the procedure "CHANGE_LANGUAGE" that accepts as
 parameter the number corresponding to the language asked. (1=English,
 2=Fran‡ais, 3=Espanol).

 Functioning :
 Words and each language stamps are in fact external to all program MOS.
 They are found in an external file in the system directory of MOS. A file
 for each language are therefore defined. You will find next files:
 ENGLISH.LOC, FRENCH.LOC, ESPANOL..LOC. These files are vital for a normal
 functioning of MOS. If to the launching MOS does not get find them, a
 message of error will make you know that the interface will be difficultly
 usable. You have in this case to specify in the file of initialisation of
 your software the directory where is found these files Has the Line "Working
 Directory=" Specify the exact path of the system directory.

 Files ".LOC" are in fact composed of two parts :
 The first part contains stamps of errors that can occur during the execution
 of a program. The first list corresponds to errors generated by the Turbo
 Pascal, and the second list, are errors generated by MOS.
 The second part of files ".LOC" corresponds to stamps of all masks displayed
 by MOS.

 All stamps or errors are preceded of a number. This number allows MOS to
 know what stamp it has to display by using the procedure
 "LOC(Numbero_of_String)". You can you also to use this procedure to localize
 your software.

 Location of your software MOS :
 Thanks to the utilization of files ".LOC", you can you also to benefit from
 the possibility to localize your clean software.  

 Example : You want to localize the display of a clean error to your software.
 Publish the three files ".LOC" and add your error to the list of errors with
 a number of error used not. If then in your software the error that you have
 defined occurs, it remains you more than has not launched the procedure of
 display of the error by adding the instruction : "Nerror:=xxxx", where "xxxx"
 is the number of the new error that you have defined.

 Example : You want to localize the display of a text for one of your
 software.
 Edit the three files ".LOC" and add your stamp at the end of stamp list
 with a number of stamp used not. Then, to add in your program the next
 instruction: "Loc(xxxx)" where "xxxx" is the number of the stamp that you
 come to define, and "Loc" a function that return you the stamp that you have
 defined.

 As you see the utilization of files ".LOC" is limited only by your
 imagination. You can even to define a new language for the interface by
 replacing all stamps and errors by these of a new language. Under reserve
 nevertheless to keep the same name of files.

 XMS memory and location :
 If your PC possesses the XMS memory, whole stamps of the used language will
 be loaded in memory to the launching of your software. IF on the other
 hand have no XMS memory, MOS will not put these stamps in memory, and will
 be going to seek them to each asks in files ".LOC" on disc, what slows
 considerably the display of the requester and messages to the screen.
 But, that allows to keep the compatibility with PC of small configuration.

 Procedures and usable functions :

 Change_Language(LangageNumber)
 Redefines the language running the interface. "LangageNumber" has to be
 understood between 1 and 3.

 Loc(StringNumber) : String
 Return the stamp corresponding to the number of stamp defines in each of
 the three ".LOC".

 Location and line of order :
 You can specify a new language for the interface to the launching of all
 software MOS simply by adding the parameter "-Loc=x" in the line of orders.
 "x" being the number of the asked language (understood between 1 and 3).

 MRE and the Didacticial.
 These two software are now localized in French and English (for the Espanol,
 please wait a bit !).

: Program Execution
^External Program Execution

 You have very certainly noticed that the Turbo Pascal have a function named
 "Exec" allowing to execute an external program. It is true in theory, but in
 practice, constraints of this procedure are such, that it is difficultly
 exploitable. This is why, MOS proposes a solution of replacement of this
 procedure.
 The MOS_SWAP unit contains two procedures:
   - The first "~Execute~" replaces the procedure "Exec" of the TP7, but it is
     a lot less restrictive. It allows to execute does not import what other
     program from MOS some is the size of the other conventional memory.
   - The second procedure appoints "~DOS_SHELL~", and allows as its name
     indicates it to launch a DOS Shell as the suitable BP7.

 These two procedures need to function correctly to create a file of exchange
 on the hard disk. This file of exchange is normally created in the system
 directory during the execution of the procedure "DOS_SHELL" or "Execute".
 When you are in a DOS_SHELL, you can call again a mos program.
 The different files of exchange will be created in the system directory
 SYSTEM\SWAP and the names of the files are "MOS_SWAP.$$$", "MOS_SWAP.$01",
 etc ...

 Important remark :
 The ~Unit MOS_SWAP~ does not have to be called in one of your unit
 (forbidden), it has to be used only in your main program. More, during
 your declarations of units, MOS_SWAP has to be imperatively the last
 mentioned unit.

 Example of use
 Uses MOS_MSE,MOS_GFX,MOS_TOO,MOS_GAD,MOS_XMS,MOS_SPK,MOS_SWAP;
      {* Last mentioned unit *}

 If during of a DOS Shell or an "Execute" you desire to have more memory,
 transfert the codes of your main program in a unit.

: XMS Memory
^Memory management (XMS)

%Introduction
 I want to thank IBM and Microsoft for their idea and so much simple
 management of the PC. They have had the brilliant, extraordinary idea to
 share the memory in several parts. I would tell that it concerns an
 inheritance of the well heavy past to carry today, and this are programmers
 that once of more undergo some consequences.
 For these that would not know it again, the PC has 3 memory type
 (I simplify to the maximum, my goal being to study only the XMS.
  0               --->    640  Kb         Conventional memory.
  640 Kb          --->    1024 Kb         High memory.
  1024 Kb         --->    ???? Kb         Extended memory (XMS).

 The extended memory is not accessible directly. The driver "Himem.sys" of
 the MS-DOS allows you to access XMS and the unit MOS_XMS will help you
 considerably.

%Problem of XMS memory under BP ?

 If you use BP or TPX, you have had to notice that these programs monopolize
 all the XMS, and that to make your software, it would be necessary you
 theoretically to exit to each time of BP or TPX to launch the program that
 you are creating (Not practical).
 Here is the solution :
 Hit this under DOS before to launch BP or TPX :

	SET DPMIMEM=MAXMEM xxxx

 With xxxx a number that tell to the BP or TPX not to use more than xxxx
 memory Kb XMS. If for example you have 16 Mo, you can put to the place of
 xxxx 4096. If you have 8 Mo, I counsel you 2048 for xxxx.
 You can add this line in the file "AUTOEXEC.BAT", you will not need to hit
 it to each time that you want to use the Turbo Pascal.
 Don't be afraid, if you want to make a program using the XMS, there is only
 the programmer that needs to hit this command. The program that you make,
 once finished will not need this variable of environment. (This command is
 for BP and TPX only)

%Description of the XMS unit :

 This unit can be used independently of the graphic mode (even in text).
 You can use it for any other application that has no report with M.O.S.
 If you have a good knowledge on how to manage an array, or a pointer, you
 will notice that it is easy to use XMS.

%Utilization of the XMS :

 The first function to call is the function Check_XMS(size:longint) to see
 if there is enough place in XMS, and also to test if one is authorized to
 use it.
 The size has to be in bytes. A program using the XMS will begin like this:

 Begin
    If Check_XMS(Size) Then
	  Begin
	   .......
	  End Else Writeln(' XMS UNUSABLE');
 End.                    {end of the program}

%Warning :

 You msut always test with this function if you have enougth free XMS
 memory. Before all, call  this function. If you do not use this function,
 all program will bug...
 You are now warned, acted consequently.

%Limitations of utilization of the XMS memory

 All allocation of the XMS can not exceed 64Mo (In theory, because I have
 not unfortunately been able to test). This limitation is well minor.

 Other more problematical limitation:
 The driver "HIMEM.SYS" limits the number of Handle (I would explain you what
 is a handle a bit more far in this chapter) to 32. Each time that you
 declare or that you use a variable of type "XMSHANDLE" or "XMS_TAB", you use
 an Handle.
 You can modify this number using a number understood between 0 and 128 in
 the file "CONFIG.SYS" to the line where is found the next sentence
 "Device=Himem.SYS". You have to add ahead this number the parameter
 "/NumHandle=128".
 It is necessary to know also that some programs reside (as Smartdrive.. .)
 use also handles. For example on my PC, once my programs reside loaded, it
 does not remain me more than 24 handles, that means that these programs use
 8 handles.

 More, if you do not liberate a handle at the end of a program, it is lost
 until what you make a reset. Similarly this XMS memory allocated is lost.

%But finally,  what is a handle ???

 A handle is materialized in Pascal with a WORD. All allocation of the XMS is
 represented by a number. This number is provided you during each allocation
 and it represents by simplifying a pointer on a busy XMS block or that is
 going it to be.

%Use the XMS as a pointer :
 Using MOS_XMS unit,can be as easy as management of pointers in the
 conventional RAM:
       Analogy:
  Type Pointer            <------>        Type TXMSHandle
  GetMem                  <------>        ~XMS_GetMem~
  FreeMem                 <------>        ~XMS_FreeMem~

 Then, the procedure ~RAM_TO_XMS~ copies a block of Memory conventional RAM to
 the XMS, and the procedure ~XMS_TO_RAM~ makes the opposite.

%Use the XMS as an array :
 I remind you the notion of cell of an array:  
 In pascal, when you use an array, you specify between hooks the cell:
 For example T[i], i is the cell.
	A declaration of table in Pascal is made thus:
 Var Tab:Array[1..100] of What_you_want;
 In this example, 1 is called minimum cell, and 100 maximum cell.

	An array in XMS will have a type TXMS_TAB.

 You will declare a variable like this :
 Var Name_of_array:TXMS_TAB;

 When you want to use the XMS as an array, it is necessary to  be sure that
 it is possible, it is the case if the function Init_XMSArray send True.
 The function ~Init_XMSArray~, in the case where it returns True, creates and
 initials the table in XMS.
 To end the XMS memory allocation use ~End_XMSArray~

%Test if there is an error :

 When you use XMS functions, some errors could occurs :
 After every use of a XMS function, test if XMS_Error=0 or Not.
 If XMS_Error<>0 Then an error occurs (See also XMS_Error Codes)
 If XMS_Error=0 Then no errors was found.

  Potential XMS Error Codes:                                            
  XMS_Error=                                                            
       80h if the function is not implemented                           
       81h if a VDISK device is detected                                
       82h if an A20 error occurs                                       
       8Eh if a general driver error occurs                             
       8Fh if an unrecoverable driver error occurs                      
       90h if the HMA does not exist                                    
       91h if the HMA is already in use                                 
       92h if DX is less than the /HMAMIN= parameter                    
       93h if the HMA is not allocated                                  
       94h if the A20 line is still enabled                             
       A0h if all extended memory is allocated                          
       A1h if all available extended memory handles are in use          
       A2h if the handle is invalid                                     
       A3h if the SourceHandle is invalid                               
       A4h if the SourceOffset is invalid                               
       A5h if the DestHandle is invalid                                 
       A6h if the DestOffset is invalid                                 
       A7h if the Length is invalid                                     
       A8h if the move has an invalid overlap                           
       A9h if a parity error occurs                                     
       AAh if the block is not locked                                   
       ABh if the block is locked                                       
       ACh if the block's lock count overflows                          
       ADh if the lock fails                                            
       B0h if a smaller UMB is available                                
       B1h if no UMBs are available                                     
       B2h if the UMB segment number is invalid                         
                                                                        
         Errors not return by Himem, but by MOS_XMS                     
                                                                        
       C0h if himem.sys is not installed in memory                      
       C1h if the version of himem.sys < 3.0 (Can use XMS)              
       C2h if all the xms memory is full                                
       C3h Not enought XMS memory                                       
       CAh Error in a XMS_Put/GetImage.                                 
       CBh Error VESA_GetImage (Need more than 1 XMS Mo (16 screens)    
       CCh Error XMS_PutImage (Not enought conventional memory)         
                                                                        

: Units replacement 
^Units replacement (CRT, GPH)

%CRT unit
 MOS replace the Tp7 CRT unit by MOS_CRT. MOS_CRT is more powerful (support
 redirection (>, <, >>) parameters).
 You will find all the functions of CRT in MOS_CRT.
 Please use this unit instead of CRT.
 See also : ~Unit MOS_CRT~

%GRAPH unit
 MOS replace the Tp7 GRAPH unit by MOS_GPH. MOS_GPH is faster and there is
 some differences :
  - MOS_GPH works only on VGA and VESA modes.
  - MOS_GPH don't use any BGI.
  - All the functions of MOS_GPH are preceded by "VESA_"
  - ~VESA_Initgraph~ parameters are differents
  - CHR functions are more powerful.
  - Some functions of Tp7 GRAPH unit are missing.
  - SetViewPortType renamed TSetViewPortType
 If you use MOS, don't use Graph and Crt unit from tp7, else there will be
 bugs.
 See also :~Unit MOS_GPH~

: Unit Tree
                             SWAP
                          TSK |
                           |  |
                          SYS |
                ----------/ \ |
               /         /   REQ
              /         /    /|\------------------------------
             /          |   / | \                            |
            /          COR /  |  \                           |
           /            | /   |   \                          |
          /             \ |  DIR  |                          |
         /               \|   |   |                          |
        /                OCG EZR MEN                         |
       HAR   CAR          \  /    |                          |
        /\    |            \/     /                          |
       /  \--------------------  /                           |
       |                 |    | /                            |
       |                LIS  WIN                             |
       |                   \  |                              |
       |             PRO    \ |                              |
       |              \ FLI  GAD                             |
       |               \ \    |                              |
       |                \ \  BMP                             |
       |                 \ \  |                              |
       |                  \ \GFX                             |
       |                   \  |                              |
       |                    \TOO                             |
       |                      |                              |
       |                     BLK                             |
       |                      |                              |
       |                     KBD                             |
       |                      |                              |
       |                     MSE                             |
       |                      |                              |
       |                     BAS                             |
       |                      |                              |
       |        -----------------------------------------    |
       |        |    |    |                        |    |    |
       |        |   DEB   |                        |    |    |
       |        |    |    |                        |    |    |
       |       COL  XMS   |                        |    |    |
       |        |    |    |                        |    |    |
       |        ----GPH  WAV                       |    |    |
       |             /\  /                         |    |    |
       |            /  \/                          |    |    |
       |           /  FIL                          |    |    |
       |          /    |                           |    |    |
       |         /    DSK                          |    |    |
       |        /     /|\-------                   |    |    |
       |       /     / | \     |                   |    |    |
       |      /     / ASM CRT  |                   |    |    |
       |     /     /   |   |   |                   |    |    |
      CPU  VESA   STR VAR DOS MEM                 IPX  LFN  MAT  CNV

 INI
 HPT  HRR

