Old BASIC, C and other source code

Old Content

This content is old! It’s still useful, but it’s old, and there may be bit rot, newer/better tools or ways to do things. Sanity check and do your research.

Source Code

I plan to move all of this to https://github.com/vossenjp/ at some point…

Batch Files

See my Windows Shell Scripting page.


(UNIX) Shell Scripts

  • checkmd5sum A trivial script to compare MD5 hashs for downloads ISOs and software.
  • web A simple wrapper for use with GenSite.pl.

C, (& BASIC)

See Dave Navarro’s Win32 console CMD Tools written in BASIC.

  • Pause.c A tiny C program that does the same thing as the DOS pause command.
  • UUConvert.c An old program that reassembles and uu-decodes binary Usenet threads saved by old mail readers such as Tin. I did not write this and I don’t know who did.

Assembly SCR programs

This zip file is a collection of old “scr” programs, many collected from old computer magazines. Here is a listing:

ADDTOIT.SCR   Extend path environment variable to any length.
ALREADY.SCR   Run programs or batch files only ONCE a day, at the first BOOT-UP.
ANSITEST.SCR  Returns an ERRORLEVEL 0 if Ansi.sys is active, 1 if it is not.
ANTIBOOT.SCR  Disables CTRL-ALT-DEL keyboard re-boot.
AUTOASK.SCR   Returns the ASCII code of the character entered at the prompt.
AUTOCAPS.SCR  Automatically turns the CAPs lock OFF when you press the shift key.
BIGBUF.SCR    TSR to enlarge DOS's usual 15 character keyboard buffer to 127.
BUFFER.SCR    Stuffs characters into the key buffer.
CLDBOOT.SCR   Cold boot the PC.
CLEARKEY.SCR  Empty the keyboard buffer
D2H.SCR       Convert decimal numbers to hexadecimal.
ENCRYPT.SCR   Simple file encryption (use PGP or something better instead).
ESC.SCR       Inserts the escape character in batch files (eg. esc [10m).
FASTKEY.SCR   Resets the keyboard repeat rate and delay rate to the fastest possible.
FULLSCR.SCR   Script to switch DOS session to full screen in MS-Win.
H2D.SCR       Convert hexadecimal numbers to decimal.
ISAREADY.TXT  Detail and batch files with a utility to test if Drive a: is ready.
ISAREADY.SCR  Utility to test if Drive a: is ready.
KEYCODE.SCR   Returns the ASCII and scan codes for pressed keys.
MEGSFREE.SCR  Returns an ERRORLEVEL = to the number of free megs.
NOPRSCR.SCR   Turns OFF the prn-scr key.
NOSOUND.SCR   Disable your PC's internal speaker.
NOWAIT.SCR    Resets the number of re-tries BIOS makes to the printer.
NUMLOCK.SCR   Toggles the numlock key.
PRSCR.SCR     Turns ON the prn-scr key.
PRTLOG.SCR    Toggle print logging of the command line.
REBOOT.SCR    Warm boot the PC.
RENDIR.SCR    Rename directories.
SHIFTKEY.SCR  Change the bypass autoexec.bat key in Windows.
SHIFTMOD.SCR  Make " , " & " . " keys "unshifted".
WAIT.SCR      Timed pause.

Other

Here’s a very simple awk script to prepare text for inclusion into a HTML file by changing URL’s in a plain-text file into into HTML links to that URL. I’m not really sure who wrote it, but I didn’t.

See this zip file for some date and time related code and routines. I didn’t write any of this either.


Documents

Old Content

This content is old! It’s still useful, but it’s old, and there may be bit rot, newer/better tools or ways to do things. Sanity check and do your research.

Subsections of Source

Black Page

Description

Programs to print a BLACK page to an HP LaserJet. I plan to move this to https://github.com/vossenjp/ at some point…

C Source

#include <stdio.h>
/* Program to print a BLACK page to an HP LaserJet */
main()
{  /* begin of main */

        printf("\n\n\nBlack    PC Computing October 1991");
        printf("\n\nNow printing black page...\n");

        fprintf(stdprn,"%c%s",'\33',"&l0E");
        fprintf(stdprn,"%c%s",'\33',"&l0L");
        fprintf(stdprn,"%c%s",'\33',"*p0x0Y");
        fprintf(stdprn,"%c%s",'\33',"*c2400a3300B");
        fprintf(stdprn,"%c%s",'\33',"*c0P");
        fprintf(stdprn,"%c%s",'\33',"E");

}  /* end of main */

BASIC Source

10 REM Program to print a BLACK page on an HP LaserJet
20 PRINT : PRINT : PRINT "BLACK PC Computing October 1991"
30 PRINT : PRINT "Now printing Black page..."
40 OPEN "lpt1" FOR OUTPUT AS #1
50 PRINT #1, CHR$(27) + "&l0E"
60 PRINT #1, CHR$(27) + "&l0L"
70 PRINT #1, CHR$(27) + "*p0x0Y"
80 PRINT #1, CHR$(27) + "*c2400a3300B"
90 PRINT #1, CHR$(27) + "*c0P"
100 PRINT #1, CHR$(27) + "E"
110 CLOSE #1

Perl Source Code

Description

I plan to move all of this to https://github.com/vossenjp/ at some point…

When saving, rename from *.pl.txt to *.pl or whatever you use for Perl. If using on Unix, you may need to convert CRLF to LF, and modify the “shebang” line (e.g. #!/usr/local/bin). “CleanUp” can fix the line termination. Or find a good dos2unix and unix2dos program like those found in the UNXUtils.

Perl (Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister) is an interpreted language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information. It’s also a good language for many system management tasks. Start at www.perl.com, and check getting the latest Perl. See the Win32 section especially if you use Win95 or WinNT (Hint: these versions can access the NT event logs, making collection and auditing them much easier…). I use ActiveState’s ActivePerl. I’ve also used IndigoStar’s IndigoPerl (which has Apache built in) and Perl2Exe which can “compile” Perl. And check out the Open Perl IDE.


Scripts

Clicking on the name of a script will open the code here, so you probably want to open ina a new tab instead.

CleanUp v1.9 2002-10-06
General purpose utility to clean up messy text files. Can convert tabs (see Tab above), UPPER or lower case the entire file, remove leading “>”, trim, convert CRLF <–> LF, number output, etc. Ironocally, the code for this is very messy too. One of these days I need to start fresh, but…
CSV2html v2.3 2005-10-07
Turn a csv file into a simple HTML table. (Similar to HTMLTable.pl)
CSV2tab v3.5 2008-09-27
Convert CSV files to TAB delimited files.

DNSLookup.pl 1.0 2002-11-22 " Lookup IPAs and get hostnames from STDIN or a file.

DoMath v1.2 2002-10-22
Perform math operations on arbitrary lines of numerical input
GenFiles v1.0 1998-03-07
Creates files of a certain size for testing purposes.
GenPass v3.0 2005-08-26
Generate random passwords of arbitrary length and complexity. v3 is a re-write to clean up the code and make it more modular. It also now changes interface modes based on script name (.cgi or .pl, still need to manually edit and add -T). New for 2.2 was dual interfaces–GenPass can run as a CGI script or from the command line. New for 2.1 was a Hex option, for generating WEP keys. Try the CGI/web interface!
GrepCount.pl v1.0 2003-03-21
Count the frequency of a list of regular expressions in arbitrary input data so that a file for use with ’egrep -f’ can have the most frequent expressions first so it runs faster.
HTMLList.pl 1.0 2003-11-30
Create a simple HTML list from text input.
HTMLTable.pl 1.1 2003-11-10
Create a simple HTML table from (TAB delimited) text input. (Similar to csv2html.pl)
ipa2int.pl 1.1 2004-01-30
Translate an IP Address to a MySQL-style integer, or reverse. Useful for pre-precessing data (i.e. FW logs) before it is imported into MySQL.
pivot.pl 1.0 2003-09-19
Pivot cells (e.g. columns to rows) in a table
subtotal.pl v1.1 2003-06-26
Subtotal arbitrary line items. Assumes that the number to subtotal is the first field and that the rest of the line is the keyfield (i.e. hash value).
Merge v2.7 2002-09-30
A very UGLY and complicated but flexible generic program to merge two data files with a common, unique key.
MergeL v1.3a 2003-01-13
A more simple and generic program to merge lines two data files with a common, unique key. This program is similar to the UNIX join command, but is intended more to process TAB delimited files cut from and pasted back into a spreadsheet. It creates a table or matrix of data, where each line is merged on a unique key (hence MergeL).
WordFreq v1.0 2001-12-05
Count word frequency in a text file. Basics from 8.3, page 280 of the Perl Cookbook, I just added stop words.

GenSite

GenSite is the simple script (relative to “real” Content Management Systems (CMS) anyway) that created the HTML code for this site up until 2026.

My main constraint is that the ISP where most of the site is hosted does not support SSI, CGI, or anything else that would facilitate a modern site. I have various reasons for staying there, not the least of which is inertia. (That changed probably decades ago…)

So I needed a simple solution that would create a navigable site without any those technologies. Also, after the last redesign JavaScript fiasco, I wanted totally PURE HTML. Since the site is mostly static, that was fine, except for being able to actually maintain it. So I wrote this.

See the script code for lots more details.

GenSite.pl 1.12 2003-12-22
Generate a static HTML-only web site from templates. (See also my GenSite wrapper web.)

OLD

Old Content

This content is old! It’s still useful, but it’s old, and there may be bit rot, newer/better tools or ways to do things. Sanity check and do your research.

Some Perl modules you might need (especially since I used them in some of these scripts). Just extract the files (use WinZip) and copy *.pm to \perl\lib\Number, \perl\lib\time or the correct path.

  • Fix-wls v1.0a 19-Mar-2000 Converts those annoying WatchGuard *.WLS files to Self-Extracting archives. This is obsolete with current versions of Live Security.
  • LCaseHTML v1.1 05-Apr-1996 Converts HTML commands to lower case in HTML code, overwriting original file. (I got tired of inconsistent case on my HTML code. Talk about anal…)
  • URL2HTML v1.1b 15-Nov-2000 Converts URLs (in the form of URL{tab}description) to Bulleted HTML lists.

Reboot Source Code

Source

Source Code for programs that reboot your PC. I plan to move this to https://github.com/vossenjp/ at some point…

Reboot.c

#define MAGIC 0 /* for cold restart */
/* #define MAGIC 0x1234 /* for warm restart */

#define BOOT_SEG 0xffffL
#define BOOT_OFF 0x0000L
#define BOOT_ADR ((BOOT_SEG << 16) | BOOT_OFF)

#define DOS_SEG 0x0040L
#define RESET_FLAG 0x0072L
#define RESET_ADR ((DOS_SEG << 16) | RESET_FLAG)

main()
{
    void ((far *fp)()) = (void (far *)()) BOOT_ADR;

    *(int far *)RESET_ADR = MAGIC;
    (*fp)();
    return 0; /* never gets here, but keeps compiler happy */
}

Reboot.bas

REM From PC Mag, Vol11 Number 5

DECLARE SUB ReBoot (Warm%)

CALL ReBoot(1)      'be sure to save this program before running it!

SUB ReBoot (Warm%) STATIC
  IF Warm% THEN                 'if they want a warm boot
    DEF SEG = 0                 'assign the value 1234 Hex
    POKE &H473, &H12            'to address 0000:0473 Hex
    POKE &H472, &H34
  END IF
  DEF SEG = &HFFFF              'either way call the BIOS
  CALL Absolute(0)              'routine at FFFF:0000 Hex
END SUB

Assembly

To use these “scripts” cut&paste the source into a file, then issue the following command “debug < cldboot.scr”.

CLDBoot.scr

A 0100
MOV AX,40
MOV DS,AX
JMP FFFF:0000

N CLDBOOT.COM
RCX
10
W
Q

WRMBoot.scr

A 0100
MOV AX,40
MOV DS,AX
MOV WORD PTR [72],1234
JMP FFFF:0000

N REBOOT.COM
RCX
10
W
Q