═══ 1. Introduction and Ordering ═══ Virtual Pascal is a professional quality 32-bit Object Pascal compiler for OS/2 version 2.0 or later. It includes both a command line compiler and an Integrated Development Environment (IDE) with fully integrated debugger. VP can be used to develop both text mode and Presentation Manager applications for OS/2 and to port existing software products written in Borland Pascal from DOS to OS/2. This text is meant as an overview of the key features of Virtual Pascal, as well as touch on the subject of further development. For descriptions on how to use a specific feature, please refer to the relevant sections in Volume 2 of this manual. Inspired by Borland Pascal and Turbo Debugger, VP/2 offers two distinct versions of the powerful integrated development environment. The two environments look very much the same and share most capabilities, but serve two different purposes. The text-only version of the VP/2 IDE runs on any computer running OS/2 v2.0 or later, even without the OS/2 Presentation Manager installed. It runs either in full screen mode or in any size window on the OS/2 desktop and offers the fastest possible operation. The drawback of this environment is the fact that OS/2's design, with only a single PM message queue, makes the writing and debugging of Presentation Manager applications difficult . The PM version of the VP/2 IDE was written to work around this design limitation of OS/2, allowing you to run and debug Presentation Manager applications without fear of crashing the entire system. In addition to this, VP/PM offers a nice graphical speedbar, whose smart-icons give quick access to the most commonly used features of the IDE with only a single click of the mouse. VPPM requires OS/2 Presentation Manager and does not work if this is not present. Apart from the differences noted above, the two IDE versions remain identical in both features and usage. To order VP/2, please contact fPrint UK Ltd on one of the addresse below. At the time of writing this (8 April 1996), the price of Virtual Pascal for OS/2 v1.00 is Ь165 + shipping. fPrint UK Ltd Cambridge House 100 Cambridge Grove Hammersmith London W6 0LE United Kingdom Phone +44 (0)181 563 2359 Fax +44 (0)181 563 2361 BBS +44 (0)181 563 8624 e-mail sales@fprint.co.uk CompuServe GO FPRINT or GO OS2BVEN section 6 FidoNet 2:254/283 or the VPASCAL conference ═══ 2. Key IDE Features ═══ IDE means Integrated Development Environment and covers the visible parts of Virtual Pascal for OS/2. The IDE is where you write your programs and where your programs are debugged - in other words, a very important component.  VP/2 compiles in the background. While compilation is in progress, you can continue to edit, browse, read online help, etc.  The editor allows multiple open windows, in each of which text files of any size can be edited. Special features worth mentioning include: - Unlimited number of Undo/Redo operations. - All block operations work with 3 block types: Line, Columnar and Stream. - Clipboard operations: Cut, Copy and Paste. VP/PM uses the OS/2 clipboard, making cut/paste between VP and other applications easy. - Full Pascal syntax highlighting. Reserved words, numbers, text strings, comments and assembler statements are shown in their own configurable colour. - Search and Replace with regular expressions. - Incremental search facility. - Mouse support. Right-clicking anywhere gives you an intuitive pop-up menu offering quick access to some commonly used features. - Full keystroke macro support, including a Macro List dialog box that displays currently defined keystroke macros and lets you add, remove and edit macros.  Context-sensitive help system, including help for the IDE, the compiler and all OS/2 API function calls defined in VP/2 interface units.  Topic search from editor and help windows.  Search for text in the current topic, index or in all topics with Case Sensitive and Clipboard Copy and Copy Example commands.  The text-mode IDE runs in a window on the OS/2 desktop and can have any size up to 250x50 characters. Set your desired screen size with the OS/2 mode command and select Options|Environment|Preferences|Keep Original to make VP run without resizing the window.  VP/PM allows dynamic sizing of the work area. When the window is resized, the editor windows are resized to fit the new size. The size and font is saved when VP/PM is exited and restored when it is next started.  The Integrated Debugger is a source level debugger that uses the Editor windows to facilitate source code tracking while executing. ═══ 3. Key Debugger Features ═══ The debugger is that part of Virtual Pascal which allows you to find any problems in your programs. Having a powerful debugger with many different views is a big advantage when finding bugs in real-world programs - and the VP/2 built-in debugger offers wide selection of debugger features to use and choose from...  If the program being debugged fails with a run-time error or an exception, the source file containing the error is loaded and the cursor is positioned to the error location. If no source code is available, or debugging information is disabled, the CPU window is displayed instead, with the cursor moved to the offending instruction.  Sophisticated source tracing algorithm that allows tracing of complex lines and even exceptions and exception handlers at high speed.  Watch window showing the value of variables or even complex expressions. The window is automatically updated whenever necessary during program execution.  Call stack window, showing the call stack, including parameter values.  Breakpoints window. In addition to execution breakpoints it is possible to set up to four datapoints (supported by the 386 and later hardware), each having a condition and a pass count for triggering it and an action that can be either Break or Log.  Register window that shows the values of CPU registers and flags and allows changing them.  Numeric Coprocessor window displaying the Stack registers, the Control register and the Status register panes showing the state of the x87 coprocessor and lets you change it.  Dump window that can show the memory in all Pascal integer and floating point formats.  Object Hierarchy window, which shows an outline of your currently defined object hierarchy. Two different hierarchies are established; one for each object model supported by VP/2 and both are displayed in this window.  Inspector window, which allows the inspection of complex structured variables or types in an efficient manner.  Symbols window. Shows a list of all global and local symbols (types, constants, variables, procedures, functions) including their current values. The incremental search facility makes it easy to locate a specific symbol.  CPU window with Code, Data, Register and Stack panes displays the source lines and the corresponding disassembled instructions. The code can be patched during execution using a built-in assembler similar to the one available in asm..end statements in a program.  Log window collecting information about program flow (Module load, thread creation and termination, exceptions, breakpoints, user comments, etc). The Log window can also log expressions from Log-Points, which are similar to breakpoints, but log an expression instead of interrupting program execution.  Evaluate/Modify dialog, used to evaluate expressions and modify the value of variables at run-time.  Messages window, containing information about compilation and linking progress.  Threads dialog lets you examine all current program threads and allows you to freeze or resume them.  Exceptions dialog which lists all OS/2 system exceptions and allows you to specify whether the debugger should handle a particular exception or if the user program is responsible for handling it. This can be particularly useful for catching hard-to find bugs.  Unit dialog list, listing all units used by the program along with include files. If a unit or an include file is selected, the source file is loaded into an editor window.  The IDE can be used as a high speed assembler level debugger. Any 16- or 32- bit OS/2 executable can be loaded into the IDE using the File|Load Program menu item.  For debugging Presentation Manager programs, VP/2 features both Hard and Soft PM debugging mode. In the Hard debugging mode, the PM application being debugged is guaranteed to receive all messages in the same sequence as it would without the debugger running. In Hard mode, all other processes in the system are suspended. ═══ 4. Key Compiler Features ═══ The compiler of a Pascal environment is really what it is all about. The compiler is the component which translates your Pascal source code into efficient machine-code language and makes a program out of a text file. The VP/2 compiler is both powerful, fast and feature-rich, as can be seen from the following:  The compiler is very fast and generates efficient and small executables. On a fast machine, VP/2 compiles about 300.000 lines of Pascal source code per minute.  Borland Pascal version 7.0 compatible including the latest extensions: Open array parameters, Open strings, Null-terminated strings, Dynamic methods and Small (integer sized) sets.  Borland Delphi v1.0 compatible. All language extensions introduced by Delphi v1.0 are available in VP/2: - The new object model (class), - Exceptions (try..except, try..finally, raise), - Result variable to assign and manipulate function result values, - Run-Time Type Information (RTTI), - Functions can return results of any type except file types, - Open Array constructors, - Method pointers, - Type variant open array parameters.  Some Delphi v2.0 key features are supported: - Local thread storage using threadvars, - The Currency floating point type is supported, - Unit finalization parts, - Double slash (//) comments, - The assembler directive is not required for assembler procedures and functions.  Versatile Run-Time Library. The Crt, Dos, WinCrt, WinDos, Printers and Strings Borland-Pascal compatible units are included, as are the Math, Classes, SysUtils and TypInfo Delphi v2-compatible units.  Built-in intelligent Make and Build tools.  386/486/Pentium capable built-in assembler (BASM).  Powerful optimizations can be enabled, making the code output by VP/2 both very small and very fast. A sophisticated register allocation routine allows commonly used variables to reside 100% in registers for optimum performance and speed.  VPC can generate object files, object libraries or readable assembly source that can be compiled by TASM (Turbo Assembler) 3.0+ or MASM (Microsoft Assembler) 6.0a+ to obtain equivalent object files. This allows you to mix code written in Virtual Pascal with code written in other languages.  VPC supports the Pascal, C, StdCall and far16 Pascal (without thunking) calling conventions, allowing: - All OS/2 API functions to be called directly without special interface libraries. - OS/2 Exception handlers, Presentation Manager window functions, etc, to be written in Pascal. - 16-bit OS/2 1.x API functions to be called directly without any special interface thunk libraries.  Direct I/O port and memory access through the Port and Mem arrays.  Standard units are highly compatible with the DOS protected mode and Windows platforms of Borland Pascal.  VP/2 features Smart Linking, which lets you create tiny executables even without resorting to the use of DLLs. "Smart Linking" means that unused variables, procedures, functions and objects are not linked into the executable. Note, that source level debugging in the IDE is disabled for programs linked with Smart Linking enabled.  VP/2 can generate dynamic link libraries (DLL), usable from VP/2 programs or programs written in another language, such as C or C++.  Every definition in the interface section of a unit, including variables, typed constants, procedures, function and objects can be exported to a DLL and be used by any program using the DLL. This allows for the creation of DLLs for complex object-oriented libraries like Turbo Vision, Object professional or even the Delphi Visual Component Library.  No 64kB limits on either code segment, data segment or symbol sizes.  The ampersand character (&) is allowed as a replacement for the dollar sign ($) in compiler directives. This can be used to specify Virtual Pascal specific directives: other Pascal compilers, such as Borland Pascal, will treat these as ordinary comments.  All Borland Pascal compiler directives are accepted. The ones that have no Virtual Pascal equivalents are ignored. $A is equivalent to $AlignData.  A number of Virtual Pascal specific compiler directives are supported: AlignCode, AlignData, AlignRec, Asm, Cdecl, Far16, Frame, G3, G4, G5, Optimize, OrgName, PureInt, SmartLink, Speed, StdCall, Zd.  Long file names are supported by the run-time library: The size of the file variables has been increased to hold a long file name. The PathStr, DirStr, NameStr, ExtStr, SearchRec types in the Dos/WinDos units have been modified accordingly.  A program (.EXE) or a library (.DLL) can use either the static or a dynamic version of any unit it uses. If using the static version, the unit's object file is linked into the executable. If the dynamic version is used, the program requires the DLL to run. Full source level integrated debugging support is offered whichever method is used.  After VP/2 has been installed, two DLLs are immediately available: - VPRTL100.DLL including the System, Crt, Dos and Strings units. - TV201.DLL includes all Turbo Vision units.  Interface units providing access to all OS/2 API calls are availble: - Os2Base: Base OS/2 API calls and 16-bit OS/2 1.x API (Vio, Kbd, Mou, Mon and Nls calls). - Os2PmApi: All Presentation Manager API calls. - Os2Rexx: All REXX API calls. - Os2Def: Definitions of commonly used types and constants ═══ 5. Program Examples ═══ More than 100 examples of programming in VP/2 is included on the CD-ROM. The examples are built with the real world in mind, and attempt to exemplify situations which are either difficult or illustrate some aspect of OS/2 programming with VP/2.  All Turbo Pascal examples can be compiled by Virtual Pascal with minor changes (BreakOut, TVDemo, TVEdit, TVFM, etc.) The more interesting ones are included as OS/2 executables.  Examples that show the use of the standard units Dos, WinDos, Crt and WinCrt are included both as source code and as executables. Two Presentation Manager programs, the Triplex game and the Clock application are also available.  All relevant examples from the excellent book "The Art of OS/2 Warp Programming" are included with source code. The examples are included both as executables and with full Pascal source code and demonstrate many different aspects of programming for OS/2. Getting the above mentioned book is highly recommended in order to get the most of the examples provided.  Two examples also demonstrate the excellent compatibility with Delphi. ClsDemo and SysDemo demonstrate more than 100 functions from Classes and SysUtils, respectively - and compile with both Virtual Pascal and Delphi 2.