Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

More Routines And Variables

Character and String Routines

match=sameas(stg1,stg2); case-insensitive string match

...

See also the memory handling routines movmem(), setmem(), and repmem() on page 67.

Real-Time Routines: rtkick(), rtihdlr()

rtkick(time,rouptr); “kick off” routine after time delay

...

If you have a routine that you need to execute more often than once a second, you could register it with rtihdlr(). Once you start this, it runs the entire time the Worldgroup Major BBS server is up (don’t keep calling rtihdlr() on the routine like you could do with rtkick()). This routine will be running at interrupt level, so don’t try any DOS or GSBL calls except the chixxx() routines (see GSBL Guide). And be sure the routine uses as short a time as possible, or the server will lose its real-time responsiveness.

...

Applies to: WG3.x

Header check: btuhrt (WG2 BRKTHU.H:88, volatile unsigned long) is not declared in WG3.2; the tick counter is EXPGSBLV(volatile USHORT) ticker with btuTicker() (BRKTHU.H:214-217). hrtval() is still declared (GCOMM.H:734). The 16-bit rate and width differ from the text.

Time and Date Routines

date=today(); Find out today’s date

...

See also page 322 for reading and setting a file’s time and date.

Numeric Routines

smaller=min(a,b); Find the smaller of two numbers

...

This routine calculates a 16-bit CRC based upon the polynomial x^16+x^12+x^5+1. This is the same CRC as is computed for the XMODEM-CRC protocol.

Text File Scanning

This suite of routines can be handy for scanning one or more text files, especially if you’re looking for lines that start with some prefix string. We use these routines to scan all .MDF files for all the lines we’re interested in. For a really thorough demo of the tfsxxx() routines, see how this is done in INTEGROU.C (available with the Extended C Source Developer’s Kit).

...

This just makes sure that if a file is opened that it gets closed, which is usually a good idea. Otherwise, you need to keep calling tfsrdl() until it returns TFSDUN.

Disk I/O

bufptr=mdfgets(buffer,size,fp);
Read a line of text from a file

...

This is just like the standard fgets(), except it uses \r as a line terminator (a hard carriage return on Worldgroupthe Major BBS), and it won’t have a line terminator on the last line if the file doesn’t have it.

...

This routine checks through the DOS list of device drivers and other reserved names to make sure a proposed filename will not be misinterpreted as a device. It’s a great idea to use this routine especially if the filename is something a user typed (even if it’s the Sysop user). Did you know that writing to PRN.TXT will output to your printer? Calling rsvnam("PRN.TXT") will return 1 and catch this and other disasters.

...

Find First Matching File, Find Next

...

The following routines can be used to find out if a file exists, or to get help from DOS with breaking down a wildcard file specification (such as *.EXE) into its component files:

...

You can refer to a DOS technical manual on interrupt 21H, function 4EH, for details on the other bits.

Everything Else

cpu=cputype(); Returns 88, 186, 286, 386

...

pascrit(); Set the DOS critical error handler to a routine that retries three times then pops up a friendly window. Must run with the GSBL (Software Breakthrough).

Boolean Values Exchanged With Client Apps

Applies to: WG2+

In VB, True is -1 and False is 0. If ok is 1, the following line will work:

...