home *** CD-ROM | disk | FTP | other *** search
- Additional Strings Functions and Procedures
-
-
- This UNIT contains some additional string functions which for reasons of their
- own the wizards at Borland left out of Turbo V4.0. I have found these routines
- to be quite useful and decided to implement them as a UNIT.
-
- When using these routines you will notice that many of them require a
- parameter in the form of SIZEOF(x). I did this so that the assembly routine
- which actually performs the function would have the maximum size of the
- string variable being used and could therefore check for overflow. Only the
- StringOf function does not require this.
-
- I have found the Extract type functions most useful in scanning input
- parameters. If you do a lot of processing of words they again will prove
- quite useful and most efficient as in addition to copying the substring they
- also remove it from the source string.
-
- All routines are implemented in assembly code for maximum speed. I have
- included the assembly source in case you decide you don't like the name of
- a routine (often the case with myself) or some such thing.
-
- If any errors are found please notify me via the BPROGA forum or via
- EASYPLEX. I would also like to hear of any ideas you may have for additional
- functions to be included in the future.
-
- Happy Programming
-
- Jan St Martin
-
-
- -----------------------------------------------------------------------------
-
-
-
-
- ExtractForCount
-
- Declaration
- target_str := ExtractForCount(source_string, sizeof(target_string, start_pos)
-
- Operation
- This FUNCTION will move 'n' characters from the source string into the
- target string starting from the character in the source string pointed
- to by start_pos). Once the characters have been moved into the target
- string they are deleted from the source string.
-
- ExtractToChar
-
- Declaration
- target_str := ExtractToChar(source_str, sizeof(target_str), search_char)
-
- Operation
- This FUNCTION will move characters from the source string into the target
- string UNTIL the a character matching search_char is encountered. When
- the search_char is matched character movement stops (movement does not
- include the search_char). The characters that were moved are deleted
- from the source string.
-
- Translate
-
- Declaration
- Translate(str_to_translate, translate_table);
-
- Operation
- This PROCEDURE will translate the string indicated by str_to_translate
- according to the 256 character translation table specified by the
- second operand. The translation table is assumed to be 256 bytes in
- length and must be setup by the caller.
-
- For each byte in the str_to_translate, the character is extracted and
- it's logical value is added to the starting address of the translation
- table. The table character pointed by that sum is used to replace the
- original character.
-
- PadLeft
-
- Declaration
- PadLeft(string, sizeof(string), new_length, pad_char);
-
- Operation
- This PROCEDURE will insert pad_char into the 1st position of string
- until the length of string is equal to new_length or the string
- reaches it's maximum size.
-
-
- PadRight
-
- Declaration
- PadRight(string, sizeof(string), new_length, pad_char);
-
- Operation
- This PROCEDURE will insert pad_char into the LAST position of string
- until the length of string is equal to new_length or the string
- reaches it's maximum size.
-
- Uppercase
-
- Declaration
- target_str := Uppercase (source_str);
-
- Operation
- This FUNCTION will convert each character within the range of a..z in
- the source_string into it's corresponding uppercase character and place
- it into the target_string.
-
- StringOf
-
- Declaration
- target_str := StringOf (pad_char, string_len);
-
- Operation
- This FUNCTION will create a string containing string_len occurances of
- pad_char. The original contents of the string are ignored and the user
- is assumed to know what he/she is doing as there is no check for excedding
- the maximum length of the string.
-
-
-
-
-
- Graph unit
- ARTY4 PAS - Example program for the Graph unit
- GRLINK PAS - Example program for the Graph unit that shows how to
- link font and driver files into an .EXE file.
- DRIVERS PAS - Example unit for use with GRLINK.PAS
- FONTS PAS - Example unit source for use with GRLINK.PAS
- GRLINK MAK - Make file for use with GRLINK.PAS
- MCALC PAS - MicroCalc example program
- MC?????? PAS - Supporting units for MicroCalc
- MCMVSMEM ASM - Assembler routine used by MicroCalc
- MCMVSMEM OBJ - Assembled version of MCMVSMEM.ASM
- UNPACK COM - Utility to unpack GREXAMPL.ARC
-
- GREXAMPL ARC - Binary file that contains revised graphics
- examples from the programs for GRAPH unit.
-
- FILELIST - List of the example programs in GREXAMPL.ARC
- and the corresponding procedure/function names
- and manual page numbers.
- ARC PAS - Arc example program
- ARCCOORD PAS - GetArcCoords example program
- ASPECT PAS - GetAspectRatio example program
- BAR PAS - Bar example program
- BAR3D PAS - Bar3D example program
- CIRCLE PAS - Circle example program
- CLOSEGR PAS - CloseGraph example program
- CLRDEV PAS - ClearDevice example program
- CLRVP PAS - ClearViewPort example program
- DETECT PAS - DetectGraph example program
- DRPOLY PAS - DrawPoly example program
- ELLIPSE PAS - Ellipse example program
- FILLPOLY PAS - FillPoly example program
- FLOOD PAS - FloodFill example program
- GETBKCOL PAS - GetBkColor example program
- GETCOL PAS - GetColor example program
- GETFILLS PAS - GetFillSettings example program
- GETGRMD PAS - GetGraphMode example program
- GETLNS PAS - GetLineSettings example program
- GETMAXX PAS - GetMaxX example program
- GETMAXY PAS - GetMaxY example program
- GETPAL PAS - GetPalette example program
- GETPIX PAS - GetPixel example program
- GETTXTS PAS - GetTxtSettings example program
- GETVS PAS - GetViewSettings example program
- GETX PAS - GetX example program
- GETY PAS - GetY example program
- GRERRMSG PAS - GraphErrorMsg example program
- GRRES PAS - GraphResult example program
- IMSIZE PAS - ImageSize example program
- INITGR PAS - InitGraph example program
- LINE PAS - Line example program
- LINEREL PAS - LineRel example program
- LINETO PAS - LineTo example program
- MOVEREL PAS - MoveRel example program
- MOVETO PAS - MoveTo example programs
- OUTTXT PAS - OutText example program
- OUTTXTXY PAS - OutTextXY example program
- PIESLICE PAS - PieSlice example program
- PUTIM PAS - PutImage example program
- PUTPIX PAS - PutPixel example program
- RECT PAS - Rectangle example program
- RESCRT PAS - RestoreCrtMode example program
- SETACTPG PAS - SetActivePage example program
- SETALLP PAS - SetAllPalette example program
- SETBKCOL PAS - SetBkColor example program
- SETCOL PAS - SetColor example program
- SETFLPAT PAS - SetFillPattern example program
- SETGRMOD PAS - SetGraphMode example program
- SETLNSTY PAS - SetLineStyle example program
- SETPAL PAS - SetPalette example program
- SETTXTJS PAS - SetTextJustify example program
- SETTXTST PAS - SetTextStyle example program
- SETVISPG PAS - SetVisualPage example program
- SETVP PAS - SetViewPort example program
- TXTHT PAS - TextHeight example program
-
-
-
- 2. HOW TO GET HELP
- ------------------
- If you need help with Turbo Pascal, please read this file and the
- Reference Manual.
-
- If you still have a question and need technical assistance, help is
- available from the following sources:
-
- 1. Type GO BOR on the CompuServe bulletin board system for instant
- access to the Borland forums with their libraries of technical
- information and answers to common questions. In addition, all
- example programs from the manual are available on CompuServe in
- machine-readable form.
-
- If you are not a member of CompuServe, see the enclosed special
- offer, and write for full details on how to receive a free IntroPak
- containing a $15 credit toward your first month's online charges.
-
- 2. Check with your local software dealer or users' group.
-
- 3. Write to: Borland International
- Turbo Pascal Technical Support
- 4585 Scotts Valley Drive
- Scotts Valley, CA 95066
-
- Please remember to include your serial number or we will be unable
- to process your letter.
-
- 4. If you have an urgent problem that cannot wait, you can call the
- Borland Technical Support Department at (408) 438-5300.
-
- Please have the following information ready before calling:
-
- A. Product name and serial number from your original distribution
- disk. Please have your serial number ready or we will be
- unable to process your call.
-
- B. Computer brand, model, and the brands and model numbers of any
- additional hardware.
-
- C. Operating system and version number (the version number can be
- determined by typing VER at the DOS prompt).
-
- D. Contents of your AUTOEXEC.BAT file.
-
- E. Contents of your CONFIG.SYS file.
-
-
- 3. CORRECTIONS/ADDITIONS TO THE MANUAL
- --------------------------------------
-
- NOTE: Important corrections and additions have been made to the
- GRAPH unit documentation. For the latest information,
- refer to GRAPH.DOC on Disk III.
-
- The file GREXAMPL.ARC on Disk III is a packed file which
- contains example programs for each of the procedures and
- functions in the GRAPH unit. In order to use these files,
- you must first unpack them with UNPACK.COM. The simplest
- way to unpack the graphics examples is to type:
-
- UNPACK GREXAMPL
-
- This will extract all the files from GREXAMPL.ARC and
- place them into the current directory. For a list of other
- options, type UNPACK at the Dos prompt and hit <Enter>.
-
- P-14 Correction
- The backward slash (\) in the format command should be a forward
- slash (/): format b: /s
-
- P-19 New Help Language Reference Using Ctrl-F1
- More than 150 help screens on Turbo Pascal procedures and functions
- have been added to the online help system. These help topics include
- an introduction to each standard unit, a listing of all the
- constants, types, and variables in each of the standard units, and a
- brief description of every procedure and function described in the
- reference chapter of the Owner's Handbook (extensively
- cross-referenced).
-
- You can access these language topics using the help index, and by
- using the Help lookup editor command (Ctrl-F1). For example, go into
- the editor and type "DiskFree." Then, move the cursor back to the
- beginning of the word and press Ctrl-F1. The following help screen
- will be displayed:
-
- function DiskFree(Drive: word) : longint;
-
- Returns the number of free bytes of a
- specified disk drive.
-
- Unit name Dos
-
- See also DiskSize, GetDir
-
- If a keyword is not found in the help system, you are given a help
- screen that describes how to use Ctrl-F1. Ctrl-F1 is an editor
- command that can be redefined using TINST (described in Appendix F).
-
- The identifiers referenced under "Unit name" and "See also" are also
- help keywords. This means you can get more help on these items by
- using the cursor control keys and pressing <Enter>.
-
- P-20 Using Alt-F1 for Online Help
- Some help screens are now combined into groups, and the PgUp and
- PgDn keys can be used to move around within a help group. In
- addition, the Alt-F1 hot key now remembers groups of screens that
- were previously viewed, rather than each individual screen. Type
- PgUp to travel backward through a help group; type PgDn to go
- forward. A PgUp or PgDn indicator will be present in the lower right
- corner of the help window if you are inside a help group; otherwise,
- the PgUp and PgDn keys have no effect.
-
- P-30 The variable ErrorCode in example MYTHIRD.PAS should be changed
- to type integer.
-
- P-31 There is a missing less than character (<) in the second While
- statement in the example at the top of the page. The example reads
-
- while Y1 = Finish do
-
- but should read
-
- while Y1 <= Finish do
-
- or else the statement will never be True (since it was initialized
- to Start on the preceding line).
-
- P-40 Turbo Pascal predefines a long integer constant, MaxLongInt, with
- a value of 2,147,483,647.
-
- P-41 The table at the top of page 41 should look like this:
-
- Type Range Significant Size in
- Digits Bytes
- -------------------------------------------------------------------
- real 2.9 X 10E-39 .. 1.7 X 10E38 11-12 6
- single 1.5 X 10E-45 .. 3.4 X 10E38 7-8 4
- double 5.0 X 10E-324 .. 1.7 X 10E308 15-16 8
- extended 1.9 X 10E-4951 .. 1.1 X 10E4932 19-20 10
- comp -2E+63 +1 .. 2E+63 -1 19-20 8
-
- P-63 Interface Section
- If the procedure (or function) is external, the keyword external
- may only appear in the IMPLEMENTATION section.
-
- P-123 Input and Output
- In version 3.0, you could call the procedure CLOSE on a file that
- was already closed with no results. In version 4.0, it produces an
- I/O error, which you can trap by disabling I/O error checking (via
- the {$I-} option) and testing the value returned by IOResult.
-
- P-125 Compiler Directives and Error-Checking
- The {$I} include file directive is no longer allowed between a
- begin/end pair. In addition, an include file directive must always
- have a space between the "I" and the filename.
-
- P-126 Assembly Language Usage
- Inline/external procedures and functions that used byte value
- parameters in version 3.0 often took advantage of the fact that the
- high byte of the word pushed on the stack was initialized to 0. In
- version 4.0 this initialization is not done so you will need to
- check inline/external routines to make sure they don't assume that
- the high byte is 0.
-
- P-135 New TPMAP Options
- In addition to converting a .TPM file to a .MAP file, the TPMAP
- program now also produces a text file that contains a complete list
- of all units, include files and .OBJ files used by the Turbo Pascal
- program.
-
- For example, given a file named TEST.PAS:
-
- program Test;
- uses Crt;
- begin
- ClrScr;
- Write('Turbo Pascal');
- end.
-
- then the commands
-
- tpc test /$t+
- tpmap test
-
- will (1) compile TEST.EXE and produce a TEST.TPM file and (2)
- generate TEST.MAP and TEST.DEP.
-
- Here's a dump of TEST.DEP:
-
- program TEST in TEST.PAS;
- uses
- Crt;
-
- unit Crt in CRT.PAS;
- Links
- CRT.OBJ;
-
- As you can see, the listing contains the module names (TEST, CRT),
- the corresponding file names (TEST.PAS and CRT.PAS), and a list of
- .OBJ files linked in using the {$L} compiler directive (CRT.OBJ).
- TPMAP will only produce a .MAP file if you use the /M command line
- option. Similarly, the /D option will only produce a .DEP file.
-
- P-148 Under the "Bottom Line" section, the bottom line only changes
- when you hold down the Alt key.
-
- P-148 Inserting Compiler Directives into the Editor
- A new editor command, Ctrl-F7, expands the integrated environment's
- compiler directive settings into text and inserts them at the
- beginning of the current edit file. Try loading a file into the
- editor and pressing Ctrl-F7. If you haven't changed any of the
- default switch settings on the Options/Compiler menu, the following
- text will be inserted at the top of the file in the editor:
-
- {$R-,S+,I+,D+,T-,F-,V+,B-,N-,L+ }
- {$M 16384,0,655360 }
-
- These are all the options found on the Options/Compiler and Memory
- sizes menus. In addition, any conditional defines from the
- Options/Compiler/Conditional defines menu item would have been
- inserted as {$DEFINE xxxx } directives.
-
- P-153 First Letter Movement with Directory Windows
- You can now move through the directory box by using first letter
- selection. Pressing the <B> key, for example, takes you to the first
- file name starting with "B." Pressing <B> again takes you to the
- next file name, and so on. If there are no other file names
- beginning with the letter "B," you will be taken back to the first
- one. If no file names start with the letter "B," then the cursor
- will not move. Holding down the <Shift> key and pressing <B> will
- take you to the first subdirectory that begins with the letter "B."
-
- P-158 Disregard the last sentence in the paragraph at the top of the
- page. Compiler options are discussed in the following section. There
- is no Chapter C.
-
- P-170 Pair braces commands (Editor Commands)
- Here are the correct commands for Pair braces forward and Pair
- braces backward:
-
- Pair braces forward Ctrl-Q [
- Pair braces backward Ctrl-Q ]
-
- P-170 New Editor Commands
- The following commands should be added to the table:
-
- Language help Ctrl-F1
- Insert compiler directives Ctrl-F7
-
- Refer to the P-19 and P-148 README notes above for details.
-
- P-184 Quiet Mode Compiler Option
- A quiet mode option has been added to the command-line compiler.
- With the default switches, TPC will display the file name and line
- number of the program module currently being compiled. Using the
- quiet option:
-
- TPC mystuff /Q
-
- will suppress the printing of file names and line numbers during the
- compilation. Normally, TPC reports elapsed compilation time based on
- the IBM PC's internal timer. On generic MS-DOS machines using the /Q
- option, the current file name and line number is only updated when
- files are opened and closed, and the compiler does not calculate the
- elapsed time.
-
- P-191 Add a paragraph to the description of the /R option
- for TPC:
-
- If you need to pass multiple parameters to a program when using
- the /R option, enclose ALL of the parameters in double quotes.
- Note that the first double quote must be the character immediately
- following the R in the /R option (no spaces in between). You can
- embed slashes and dashes in your parameter line:
-
- tpc mystuff /m /r"file1/a file2/b -2"
-
- In this case, three parameters would be passed to program mystuff:
- file1/a, file2/b and -2.
-
- P-192 The /x option in the example command at the bottom of
- this page should be changed to /r.
-
- P-229 Variable Typecasts: High-Word/Low-Word Example
- The built-in functions Hi and Lo return the high- and low-order
- bytes of a word or integer variable. To determine the high- and
- low-order words of a long integer variable, you should use a
- variable typecast:
-
- type
- WordRec = record { used for typecast }
- Low, High : word;
- end;
- var
- L : longint;
- begin
- L := $10000; { 65536 decimal }
- Writeln(WordRec(L).Low); { 0 }
- Writeln(WordRec(L).High); { 1 }
- end.
-
- Similarly, here's an inexpensive (code-wise) alternative to the Seg
- and Ofs functions:
-
- type
- PtrRec = record { used for typecast }
- Ofs, Seg : word;
- end;
- var
- P : pointer;
- begin
- P := Ptr($1234, $4567);
- Writeln(PtrRec(P).Ofs); { $4567 }
- Writeln(PtrRec(P).Seg); { $1234 }
- end.
-
- In this example, using a variable typecast generates less code and
- is faster than using the standard functions Seg and Ofs.
-
- P-278 Units That Use Other Units
- The uses clause in a program or unit may--but does NOT have to--name
- all units used directly or indirectly. In the example at the top of
- the page, the uses statement of program Host can be written in
- several ways:
-
- uses Unit1, Unit2; - The identifiers in the interface sections of
- both units may be referenced in program Host.
-
- uses Unit2; - Only the identifiers in the interface section
- of Unit2 may be referenced in program Host.
-
- In the second example, the compiler will recursively analyze unit
- dependencies and will correctly determine that Unit2 is dependent on
- Unit1, and that program Host is dependent on both. Note that none of
- the identifiers declared in the interface section of Unit1 are
- available to Host because it does not use Unit1 explicitly.
-
- P-280 FileMode Variable
- The FileMode variable defined by the System unit determines the
- access code passed DOS when typed and untyped files (not text files)
- are opened using the Reset procedure.
-
- The default FileMode is 2, which allows both reading and writing.
- Assigning another value to FileMode causes all subsequent Resets to
- use that mode.
-
- The range of valid FileMode values depends on the version of DOS in
- use. However, for all versions, the following modes are defined:
-
- 0 - Read only.
- 1 - Write only.
- 2 - Read/Write.
-
- DOS versions 3.x define additional modes, which are primarily
- concerned with file-sharing on networks. For further details on
- these, please refer to your DOS Programmer's Reference manual.
-
- Note: New files created using Rewrite are always opened in
- Read/Write mode, corresponding to FileMode=2.
-
- P-296 System Unit Traps Interrupt 24: SaveInt24
- The system unit contains an INT 24 handler for trapping critical
- errors. When running an .EXE program created by Turbo Pascal, a DOS
- critical error will be treated like any other I/O error: the program
- counter and an error number will display and the program will
- terminate. Disk errors are detectable by using {$I-} and checking
- IOResult.
-
- The original INT 24 vector is saved in a pointer variable in the
- System unit (SaveInt24). Here's a simple program that re-installs
- the original vector:
-
- program Restore;
- uses Dos;
- begin
- SetIntVec($24, SaveInt24); { restore original vector }
- ...
- end.
-
- P-298, 355 TextRec Record
- Here is the TextRec as it is actually declared in the Dos unit:
-
- { Textfile record }
- TextBuf = array[0..127] of char;
- TextRec = record
- Handle: word;
- Mode: word;
- BufSize: word;
- Private: word;
- BufPos: word;
- BufEnd: word;
- BufPtr: ^TextBuf;
- OpenFunc: pointer;
- InOutFunc: pointer;
- FlushFunc: pointer;
- CloseFunc: pointer;
- UserData: array[1..16] of byte;
- Name: array[0..79] of char;
- Buffer: TextBuf;
- end;
-
- P-304, 494, 511 TextMode procedure: LastMode and Font8x8
- The Mode parameter is of type word. Here is the actual TextMode
- declaration from the Crt unit:
-
- procedure TextMode(Mode: word);
-
- In addition, the Last constant described in the manual is now a word
- variable in the Crt unit and has been renamed to LastMode. Each time
- TextMode is called, the current video mode is stored in LastMode. In
- addition, LastMode is initialized at program startup to the
- then-active video mode.
-
- A new constant is now defined in Crt:
-
- const
- Font8x8 = $100;
-
- and the TextMode procedure supports 43-line mode on an EGA and
- 50-line mode on a VGA. The following call to TextMode:
-
- TextMode(CO80 + Font8x8)
-
- will reset the display into 43 lines and 80 columns on an EGA, or 50
- lines and 80 columns on a VGA with a color monitor.
- TextMode(Lo(LastMode)) always turns off 43- or 50-line mode and
- resets the display (although it leaves the video mode unchanged);
- while TextMode(Lo(LastMode) + Font8x8) will keep the video mode the
- same, but reset the display into 43 or 50 lines.
-
- If your system is in 43- or 50-line mode when you load a Turbo
- Pascal program, the mode will be preserved by the Crt startup code
- and the window variable that keeps track of the maximum number of
- lines on the screen (WindMax) will be initialized correctly.
-
- P-308, 322, 465 RestoreCrt procedure
- Instead of the RestoreCrt procedure, the Crt unit contains a
- word variable, LastMode, that can be used to restore the video
- mode detected at program startup. When execution begins, Crt stores
- the then-active video mode in LastMode. In addition, each time
- TextMode is used to change video modes, the current mode is stored
- in LastMode. Here's how to write a "well-behaved" program that will
- restore the video mode to its original state:
-
- program Video;
- uses Crt;
- var
- OrigMode : word;
- begin
- OrigMode := LastMode; { remember original mode }
- ...
- TextMode(OrigMode);
- end.
-
- Note that TextMode does not support graphics modes, and therefore
- TextMode(OrigMode) will only restore those modes supported by
- TextMode. For more information on LastMode and TextMode, refer to
- the P-304 README notes above.
-
- P-337 Use of the 8087 within OBJ Files
- The use of 8087 instructions from object code linked in from .OBJ
- files is not detected by Turbo Pascal. If you link with an .OBJ file
- that uses the math coprocessor, the .OBJ must do its own
- initialization and error-checking.
-
- P-340 The default maximum heap memory size is 640 K-bytes.
-
- P-347 MyGetMem
- To conform with the description in the text, procedure MyGetMem
- should be renamed to GetMem, and a FreeMem routine should be added.
- The two procedures should look like this:
-
- procedure GetMem(var P : pointer; Size : word);
- begin
- System.GetMem(P, (Size + 15) and $FFF0); { 16 byte blocks }
- end;
-
- procedure FreeMem(var P : pointer; Size : word);
- begin
- System.FreeMem(P, (Size + 15) and $FFF0); { 16 byte blocks }
- end;
-
- P-358 Calling Conventions and Nested Procedures and Functions
- A procedure or function is said to be nested when it is declared
- within another procedure or function. Nested procedures and
- functions always use the NEAR call model, regardless of the setting
- of the {$F} compiler switch, since they are only "visible" within a
- specific procedure or function in the same code segment.
-
- When calling a nested procedure or function, the compiler generates
- a PUSH BP instruction just before the CALL, in effect passing the
- caller's BP as an additional parameter. Once the called procedure
- has set up its own BP, the caller's BP is accessible as a word
- stored at [BP+4]. Using this "link" at [BP+4], the called procedure
- can access the local variables in the caller's stack frame. If the
- caller itself is also a nested procedure, it also has a link at
- [BP+4], and so on. The following example demonstrates how to access
- local variables from an inline statement in a nested procedure:
-
- procedure A;
- var IntA: Integer;
- procedure B;
- var IntB: Integer;
- procedure C;
- var IntC: Integer;
- begin inline(
- $8B/$46/<IntC/ { MOV AX,IntC[BP] ; AX = IntA }
- $8B/$5E/$04/ { MOV BX,[BP+4] ; BX = B's stack frame }
- $36/$8B/$47/<IntB/ { MOV AX,SS:IntB[BX] ; AX = IntB }
- $8B/$5E/$04/ { MOV BX,[BP+4] ; BX = B's stack frame }
- $36/$8B/$5F/$04/ { MOV BX,SS:[BX+4] ; BX = C's stack frame }
- $36/$8B/$47/<IntA); { MOV AX,SS:IntA[BX] ; AX = IntA }
- end {C};
- begin {B}
- end {B};
- begin {A}
- end {A};
-
- Note: Nested procedures and functions cannot be declared with the
- external directive.
-
- P-367 The comments are backward in the inline example on this page.
- POP AX comes first, followed by POP DX.
-
- function LongMul(X,Y : integer) : longint;
- inline(
- $58/ { POP AX ; Pop Y }
- $5A/ { POP DX ; Pop X }
- $F7/$EA); { IMUL DX ; DX:AX = X*Y }
-
- P-373 Example Unit: Unit AuxInOut
- The example shown at the bottom of the page is incorrect. The
- correct example is in a file named AUXINOUT.PAS on Disk II.
-
- P-402 Add the following paragraph to the description of the Eoln
- function:
-
- When checking Eoln on standard input that has not been redirected,
- the following program will wait for a carriage return to be
- entered before returning from the call to Eoln:
-
- begin
- Writeln(Eoln); { This call to Eoln will cause the program
- to wait for keyboard input }
- end.
-
- P-415 The Declaration for the GetFAttr procedure is
-
- procedure GetFAttr(var f; var Attr : word);
-
- P-497 Range-Checking With Val
- The standard procedure Val, which converts a string's contents to a
- numeric variable, performs range-checking differently depending on
- the state of {$R} and the type of the parameter V:
-
- Val(s : string; var V; var Code : integer);
-
- With range-checking on, {$R+}, an out-of-range value always
- generates a runtime error. With range-checking off, {$R-}, the
- values for an out-of-range value vary depending upon the data type
- of V. If V is a real or longint type, the value of V is undefined
- and Code returns a non-zero value. For any other numeric type, Code
- returns a value of zero and V will contain the results of an
- overflow calculation (assuming the string value is within the long
- integer range).
-
- Therefore, you should pass Val a longint variable and perform
- range-checking before making an assignment of the returned value:
-
- {$R-}
- Val('65536', LongIntVar, Code)
- if (Code <> 0) or
- (LongIntVar < 0) or (LongIntVar > 65535) then
- ... { error }
- else
- WordVar := LongIntVar;
-
- In this example, LongIntVar would be set to 65536 and Code would
- equal 0. Because 65536 is out of range for a word variable, an error
- would be reported.
-
- In addition, Val has been modified to ignore leading spaces.
-
- P-417 GetFTime
- The type was omitted from the 2nd parameter. The correct declaration
- for GetFTime is
-
- procedure GetFTime(var F; var Time: longint);
-
- P-448 MsDos procedure
- The MsDos procedure is incorrectly labeled a function. Here's the
- actual declaration as it appears in the Dos unit:
-
- procedure MsDos(var Regs : Registers);
-
- P-493 Crt Color Constants
- There are 16 foreground color constants:
-
- const
- Black = 0;
- Blue = 1;
- Green = 2;
- Cyan = 3;
- Red = 4;
- Magenta = 5;
- Brown = 6;
- LightGray = 7;
- DarkGray = 8;
- LightBlue = 9;
- LightGreen = 10;
- LightCyan = 11;
- LightRed = 12;
- LightMagenta = 13;
- Yellow = 14;
- White = 15;
-
- { Add-in for blinking }
- Blink = 128;
-
- P-499 Window
- A call to the Window procedure always moves the cursor to (1,1).
-
- P-510 Differences from 3.0: MemW, FileSize
- In version 3.0, MemW returned an integer value. In version 4.0, it
- returns a value of type word. In 4.0, Filesize of an untyped file
- will ignore a partial block when the block size is greater than 1.
-
- P-523 Standard Procedures and Functions
- In the list provided, two entries are combined into one:
-
- FillChar
- Frac
-
- P-529 Force Far Calls Compiler Directive
- The {$F} (force far calls) compiler directive has no effect on a
- nested procedure. The nested procedure always uses the near call
- model.
-
- P-565 New Utility Program: BINOBJ.EXE
- A utility program BINOBJ.EXE has been added that converts any file
- to an .OBJ file so it can be linked into a Turbo Pascal program as a
- "procedure." Refer to BINOBJ.DOC on Disk II for more information on
- this new utility.
-
- P-570 The second paragraph on this page should be replaced with the
- following:
-
- See the description of the ReadKey function on page 461 for a
- description of how to determine if an extended key (function key
- or cursor movement key) has been pressed.
-
- P-586 Automatic Compaq Detection Override
- The integrated environment will detect whether you are using a
- Compaq computer and automatically use its black and white color set.
- This gives better contrast on the composite monitors that are
- built-in to the vast majority of Compaq computers. If you are using
- a Compaq computer and a true color monitor, you can force the
- integrated environment to use its color tables by running TINST,
- typing "D" to install the Display mode, and selecting Color.
-
- P-619 to 630 New Error Messages
-
- COMPILER ERROR MESSAGES:
-
- 68 Circular unit reference
- Two units are not allowed to use each other:
-
- unit U1; unit U2;
- uses U2; uses U1;
- ... ...
-
- In this example, doing a Make on either unit will
- generate error 68.
-
- 132 Critical disk error
- A critical error occurred during compilation (e.g. drive not
- ready error).
-
- 133 Old map file
- The .TPM file is older than the corresponding .EXE file. It's an
- indication that the last time you compiled your program, a .TPM
- file was not produced. For example, if TEST.TPM is older than
- TEST.EXE, to find a runtime error you must recompile TEST.PAS
- with the {$T} compiler directive on.
-
- RUNTIME ERROR MESSAGES: Critical Errors
-
- Runtime errors fall into four categories: DOS errors (1-99),
- I/O errors (100-149), critical errors (150-199), fatal errors
- (200-249).
-
- The following critical error messages have been added since the
- manual was printed:
-
- 150 Disk is write-protected
- 151 Unknown unit
- 152 Drive not ready
- 153 Unknown command
- 154 CRC error in data
- 155 Bad drive request structure length
- 156 Disk seek error
- 157 Unknown media type
- 158 Sector not found
- 159 Printer out of paper
- 160 Device write fault
- 161 Device read fault
- 162 Hardware failure
-
- Refer to your DOS programmer's reference manual for more
- information about critical errors.