[comp.lang.pascal] Turbo Pascal units update TSPAS20.ARC

ts@uwasa.fi (Timo Salmi LASK) (07/24/90)

Mon 23-Jul-90: I have updated my Turbo Pascal (4.0, 5.0, 5.5) units
collection to be version (/pc/ts/)tspas20.arc.  Available by
anonymous ftp from chyde.uwasa.fi, Vaasa, Finland, 128.214.12.3. 
   One problem area that has intrigued me for some time is finding a
technique for storing information within an executable file and
updating that information.  I've looked into it and written a couple
of relevant procedures.  USECOUNT keeps track of how many times the
program has been run and stores the result within the .exe file. 
BRANDEXE is a more general, but also a more complicated procedure
for .exe file handling.  As an example I have a demonstration how to
tell the previous time when the program was run. 
   The function checking the on-line status of the printer
(prnonlfn) has been rewritten to work without Turbo Pascal's Crt
unit.  And an alternative printer on-line status function, LTPONLFN,
has been added.  This one should be more robust, because it actually
tries to send a carriage return to the printer, and observes the
resultant success of the operation to define the on-line status.  Of
course this is achieved by {$I-} {$I+} IOResult testing, but the
real trick here is make to system respond immediately rather than in
the default response time of up to one minute.  A new procedure
PRTSCR sends the current screen to the printer.  The new routines
GETPRTFN and SETPRT get and set respectively the number of printer
default retry times before a timeout. 
   TICKSFN is a simple complement to the TIMERFN already in the
collection.  TICKSFN gives the number of clock ticks (there are 18.2
per second) since midnight. 
   A new LASTDMFN returns the number of days in a given month and
year.  DATEOKFN tells whether a date is a valid, existing date. 
ZELLERFN lets you compare which of the two dates is earlier,
calculate the number of days between two dates etc. 
   A new FIXEDFN returns whether a drive is a fixed disk or not. 
MATHCOFN returns if a math coprocessor is present.  RS232FN returns
the number of serial ports.  PARPORFN returns the number of parallel
ports.  COUNTRFN returns the country code.  CHIPFN returns the type
of the processor chip. 
   There are new keyboard routines.  SCRLONFN gets the current
ScrollLock status.  CAPS, NUMLOCK, and SCRLOCK respectively set the
CapsLock, NumLock and ScrollLock on, or off.  They take the desired
status as a boolean argument. 
  CLS sets 25*80 text mode and clears the screen and CLS40 does
likewise for 25*40.  Crt is not required. 
   So far none of the routines in the TSPAS collection have included
any inline code.  Starting from tspas20.arc this no longer holds.  I
have tried to understand some assembler and have included also
inline code.  Be warned that I cannot give any guarantees that the
inline coded routines won't cause confusion.  Where inline code has
been used, I have stated so.  The first function to utilise this is
LOWCASFN which is the exact opposite of Turbo Pascal's own UpCase
function. 
   WARMBOOT simulating alt-clr-del, and COLDBOOT reboot with memory
tests are new, inline routines. 
   A couple of routines have been moved from one unit to another.

Summary of the Functions and procedures in the TSPAS Package

Functions are indicated by the ending FN, the procedures by the lack
of it.

TSUNTA: (uses Dos, Crt, TSUNTE)
  ATTRIBFN Color attribute for direct write to video memory
  HIGHTFN  Current height of text screen
  PANML    Scroll screen left
  PANMR    Scroll screen right
  VDAEXYFN Direct read of a screen video memory color attribute
  VDCHXY   Direct read from the screen video memory
  VIDXY    Direct write to the screen video memory
  WIDTHFN  Current width of the text screen

TSUNTB: (uses Dos)
  BINDECFN Convert binary to decimal
  BINFN    Convert decimal to binary, fast
  BITONFN  Status of a bit in a word
  CONVBFN  Convert from a number of any base to any other base
  DECBINFN Convert decimal to binary, (outdated by BINFN)
  DECHEXFN Convert decimal to hexadecimal, (outdated by HEXFN)
  HEXDECFN Convert hexadecimal to decimal
  HEXFN    Convert decimal to hexadecimal, fast
  LBINFN   Convert longint to binary
  LHEXFN   Convert longint to hexadecimal
  POWERFN  Conventional raising of a positive number to a power
  POWERGFN Generalized raising of any real to a power
  POWERLFN Raise longint to a non-negative integer power
  R16TOFN  Sixteen to a power
  TICKSFN  Count of 18.2 times per second ticks
  TIMERFN  Time elapsed since midnight
  TWOTOFN  Two to a power

TSUNTC: (uses Dos, Crt)
  PLAYNOTE Play a note
  REVCOLOR Reverse text colors (a toggle)

TSUNTD: (uses Dos)
  AUDIO    Enhanced Sound procedure, and no Crt unit needed
  DOSDELAY Delay without using the Crt unit
  GETPRTFN Get the number of default printer timeout retry times
  LEADFN   Lead a string with a multiple character (i.e. pad left)
  LOWCASFN The oppsite of UpCase (inline coded)
  LPTONLFN Get the online status of the first parallel printer
  PARSE    Extract all substrings from a string
  PRTONLFN Get the online status of a printer (may fail)
  PRTSCR   Print the current screen
  SETPRT   Set the number of default printer timeout retry times
  SPARTFN  Returns a specified substring (resembles ParamStr)
  STRCNTFN Number of substrings in a string (resembles ParamCount)
  TRAILFN  Trail a string with a multiple character (i.e. pad right)
  TRIMLFFN Trim a string left
  TRIMRGFN Trim a string right

TSUNTE: (uses Dos)
  ALLSIZFN Allocated true size of a file in bytes
  BORDER   Change border color (CGA, VGA)
  CAPS     Turn CapsLock on, or off
  CAPSONFN Get CapsLock status
  CLB      Clear the keyboard buffer
  CLUSIZFN Cluster size on a device (cluster is the allocation unit)
  CMDLNFN  Returns the entire command line
  CURSOFF  Turn off cursor (keeps other cursor attributes)
  CURSON   Turn cursor back on as it was
  CURSOR   Change cursor size
  DATEOKFN Is a date a valid, existing date
  FEXISTFN File existence status, handles ReadOnly files correctly
  FSIZEFN  File size in bytes as in directory
  LASTDMFN The number of days in a given month and year
  MONOFN   Is it a monochrome
  NUMLOCK  Turn NumLock on, or off
  NUMLONFN Get NumLock status
  SCRLOCK  Turn ScrollLock on, or off
  SCRLONFN Get ScrollLock status
  WEEKNRFN Returns the week number for a given date
  WKDAYFN  Returns modern weekday
  ZELLERFN Zeller's conguence (for comparing dates etc)

TSUNTF: (uses Dos, Crt)
  EDRDLN   Readln with line-editing potential
  EDREADLN Readln with line-editing, recall, and insert toggle
  EDREABLN Edreadln with ctrl-c and break trapping

TSUNTG: (uses Dos)
  CLS      Set 25*80 text mode and clear screen (no Crt required)
  CLS40    Set 25*40 text mode and clear screen (no Crt required)
  COLDBOOT Reboot computer, including memory tests
  DRIVESFN Number of diskette drives on the system
  DSKCNTFN Get the number of disk devices (MsDos 3+ only)
  FDRIVEFN The name of the first diskette drive on the system
  FIXEDFN  Is a drive a fixed disk or not
  GOATXY   As the ordinary GoToXY but no Crt unit required
  INDRIVFN Is a media present in the given drive
  INKEYFN  Basic-like timed character input
  KEYPREFN As the ordinary KeyPressed but no Crt unit required
  READKEFN As the ordinary ReadKey but no Crt unit required
  REVAREA  Reverse the colors of an area
  USECON   Restore write and writeln direction to the screen
  USEPRN   Redirect write and writeln to the printer
  WARMBOOT Warm reboot of the coputer (as alt-ctrl-del)
  WHEREXFN As the ordinary WhereX but no Crt unit required
  WHEREYFN As the ordinary WhereY but no Crt unit required

TSUNTH: (uses Dos)
  BRANDEXE Store information within your program's .exe file
  CHIPFN   Get the type of the processor chip
  COPYFILE Copy a file from within a Turbo Pascal program
  COUNTRFN Get country code
  GRTABLFN Has MsDos GRAFTABL been loaded or not
  ISDIRFN  Is a name a directory or not
  MATHCOFN Is a math coprocessor present
  OPENEDFN Is an assigned textfile still open or not
  PARPORFN Get the number of parallel ports (printers installed)
  ROMDTEFN Get ROM BIOS version (date)
  RS232FN  Get the number of serial ports
  USECOUNT Get the number of times the programs has been used

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun