Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change system time?

Status
Not open for further replies.

quebasic2

Programmer
Dec 17, 2002
174
IN
How can you use qbasic to change the system time?
 
Calling TIME through a shell is probably a less efficient way to set the system time. It adds the overhead of loading additional copies of the Command processor and ends up requiring a response from the user, ie: "Enter new time." Generally, shelling to command.com or cmd.exe to perform practically any task is a little "left-handed" (no offense to the lefties out there). Your project leader, system administrator, teacher... whatever... is likely to give you a piece of his mind if you try to use this approach.

If you want to get fancy, you can set the time with a bit of precision by doing it the old-fashioned way... call the venerable DOS Interrupt &H21....
[tt]
DEFINT A-Z
TYPE RegTypeX
AX AS INTEGER
BX AS INTEGER
CX AS INTEGER
DX AS INTEGER
bp AS INTEGER
si AS INTEGER
di AS INTEGER
FLAGS AS INTEGER
DS AS INTEGER
ES AS INTEGER
END TYPE
DIM inregs AS RegTypeX, Outregs AS RegTypeX
Hour = 1
Minute = 2
Second = 3
OneHundredthSecond = 4
inregs.AX = &H2D00
inregs.CX = Hour * 256 + Minute
inregs.DX = Second * 256 + OneHundredthSecond
CALL INTERRUPTX(&H21, inregs, Outregs)
[/tt]

Just a note:
[tt]TIME "01:02:03"[/tt] is the easiest way to do this, since it uses a native QB command and avoids the obvious (possibly severe) problems that can occur when one calls the wrong interrupt with unknown values loaded in the registers.
Cheers. :)


vcn.gif

Suffice it to say that adding disk drives and a disk operating system to a personal microcomputer is guaranteed to increase its power dramatically.
CP/M and the Personal Computer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top