Lloyd Robert Borrett

  search
 
Follow Lloyd on Twitter Friend Lloyd on Facebook Connect with Lloyd on LinkedIn Follow Lloyd on Pinterest
Computing

Some Impressive Tips

by Lloyd Borrett
Today's Computers, Wizard's Notebook, April 1986

  Wizard's Notebook

Wizard's Notebook

Well let's face it, I've been around personal computers for quite a while and although sometimes the result of all that experience is beneficial, at other times it leaves me a little fazed. Of late I've noticed that it has become increasingly difficult for something to really impress me, you know, really knock my socks off, like the first time I saw Lotus 1-2-3, or the first time I realised it was possible to break the copy protection mechanism on a program. Recently the spell was broken, and by the simplest solution to a rather basic problem.

It came in the form of a tip in volume 4, number 25 of PC Magazine (the US version). Not everybody has a clock/ calendar option and I know many people get frustrated when they have to enter the date and time. Because it's so tempting to just hit the Enter key when DOS asks for the date, people without hardware clocks end up with a lot of files seemingly created in the early hours of January 1, 1980.

While annoying in the home setup, this situation is intolerable in a business environment. PC users and their supervisors, tired of seeing lists of files dated 1/8/1980 might want to create the DATECHK.COM file shown in Figure 1.

Figure 1.
DEBUG
-A
XXXX:0100 MOV AH,2A   : Get Date
XXXX:0102 INT 21      :through DOS
XXXX:0104 MOV AX,CX   :Year
XXXX:0106 SUB AX,7BC  :1980 in Hex
XXXX:0109 MOV AH,4C   :Exit with error
XXXX:010B INT 21      : through DOS
XXXX:010D
-N DATECHK.COM
-R CX
CX 0000
-000D
-W
Writing 000D bytes
-Q

DATECHK.COM returns an "error" code that equals the year set in DOS minus 1980. The batch file fragment shown in Figure 2, which you can add to your AUTOEXEC.BAT file to run when you boot up, uses this error code with an ERRORLEVEL check to continually ask for the date if it's still set at 1980.

Figure 2.
echo off
cls:
:GETDATE
date
if errorlevel 1 goto GOODDATE
echo Gimme a break ---
echo   It's not 1980 anymore.
goto GETDATE
:GOODDATE

Some PC users may be annoyed, but it's for their own good.

Timed Delay

Now that I'm back to the same level of enthusiasm as most of the other personal computer users I meet, let's solve another problem.

Ever written a BASIC program and wanted to introduce a timed delay? The answer that springs immediately to mind is to create a simple null loop:

10 FOR 1=1 TO (DELAY* FACTOR): NEXT I 

where DELAY is the delay required in seconds and FACTOR is the magical number required to do it on your computer. But what if the program needs to run on different computers, eg. the plain old PC and the super fast AT? Scratch method one.

The solution I had been using was based around the qualities of the SOUND statement:

10 SOUND 32767, (DELAY*18.2): SOUND 3267,1 

This had worked on every PC configuration tested, but unfortunately I recently found the exception. The SOUND statement causes problems when using a PC in a multi-user or multi-tasking environment.

Fortunately a new solution based on the qualities of the TIMER function has been found.

10 TEMP=TIMER+DELAY:IF TEMP<86400 THEN 30
20 WHILE TIMER <86400:WEND: TEMP=TEMP-86400
30 WHILE TIMER<TEMP:WEND

As you can see, most of the code is to handle the problem caused if the delay is started before midnight with an intended completion after midnight. It works, provided other tasks don't do system resets.

Date and Time Stamp

Here's a trick to put the current date and time stamp on any of your files. Create a one line batch file called STAMP.BAT that contains the single line:

COPY %1/B+,,>NUL

where the ">NUL" supresses spurious messages. Unfortunately, this also suppresses legitimate error messages such as "File not found". To use it, just type

STAMP filename

substituting the name of the file whose date and time you want to change for "filename" in the above example. The basis for this command comes from the DOS manual. However this method includes an improvement the addition of a /B that forces DOS to copy the entire length of the files as specified by the directory entry.

When DOS concatenates files (using +), it records the current date and time in the directory. If you concatenate source files without naming a result filename, COPY will add all the files it is joining to the end of the first file in the list of filenames to be joined. Since STAMP.BAT uses only one source name, and no result name, the file is concatenated onto itself.

Lloyd Borrett is support co-ordinatorfor HiSoft Computers, president of the Australian PC User Association, founder and president of the Melbourne PC User Group, and system operator of the PC Connection bulletin board system.

Last modified: Saturday, 15 October 2011

 
 


 
 
home | about | weird mob | computing | interests | insight
Copyright © 1995-2018 Lloyd Borrett. All rights reserved.  ::  www.borrett.id.au
mob 0418 170 044  ::  tel +61 3 5904 9005  ::  email lloyd@borrett.id.au  ::  skype lloyd_borrett
twitter @borrett  ::  facebook lloyd.borrett  ::  linkedin lloydborrett