1. Re: Set/reset DOS environment variable and more...
------=_NextPart_000_00D7_01BE5701.4ED63EC0
charset="iso-8859-1"
OK, here it is a program that uses variables saved to file to determine
actions.
The following is a list of two files, save both to disk in the same
directory, and save the dat file at the end as "envrnmnt.dat"
Listing of envitest.ex
include mouse.e
include graphics.e
include machine.e
include get.e
integer key, fn, count
sequence vidseq, temp
vidseq = video_config()
if graphics_mode(17 + vidseq[VC_COLOR]) then
puts(1, "Graphics unitialized.\n")
abort(1)
end if
function GetClick(integer clck)
integer theclick
if clck > 3 or clck < 1 then
puts(1, "Invalid range for mouse button.")
abort(0)
end if
fn = open("envrnmnt.dat", "rb")
if fn = -1 then
puts(1, "Error reading envrnmnt.dat.")
abort(1)
end if
count = 1
while count <= clck do
theclick = getc(fn)
count = count + 1
end while
close(fn)
theclick = theclick - 48
return theclick
end function
procedure SetClick(integer bttn, integer val)
integer lc, mc, rc
if bttn > 3 or bttn < 1 then
puts(1, "Invalid range for mouse button.")
abort(0)
end if
if val > 1 or val < 0 then
puts(1, "Invalid range for click on or off.")
abort(0)
end if
lc = GetClick(1)
rc = GetClick(2)
mc = GetClick(3)
fn = open("envrnmnt.dat", "wb")
if fn = -1 then
puts(1, "Couldn't open envrnmnt.dat.")
abort(0)
end if
if bttn = 1 then
lc = val
elsif bttn = 2 then
mc = val
elsif bttn = 3 then
rc = val
end if
print(fn, lc)
print(fn, mc)
print(fn, rc)
close(fn)
end procedure
vidseq = video_config()
constant origin = {vidseq[VC_XPIXELS]/2, vidseq[VC_YPIXELS]/2}
constant MAX_LINE = 5
constant KEY_PRESS = 128
procedure SendMsg(object message)
if sequence(message) then
mouse_pointer(0)
position(1,1)
puts(1,"
")
position(1,1)
puts(1, message)
mouse_pointer(1)
return
end if
if message = KEY_PRESS then
if key = 108 or key = 76 then
if GetClick(1) = 1 then
SetClick(1, 0)
SendMsg("Left click checking off.")
else
SetClick(1, 1)
SendMsg("Left click checking on.")
end if
end if
if key = 109 or key = 77 then
if GetClick(2) = 1 then
SetClick(2, 0)
SendMsg("Middle click checking off.")
else
SetClick(2, 1)
SendMsg("Middle click checking on.")
end if
end if
if key = 114 or key = 82 then
if GetClick(3) = 1 then
SetClick(3, 0)
SendMsg("Right click checking off.")
else
SetClick(3, 1)
SendMsg("Right click checking on.")
end if
end if
if key = 27 then
abort(1)
end if
end if
if message = LEFT_DOWN or message = LEFT_UP then
if GetClick(1) = 1 then
SendMsg("Left mouse button clicked.")
end if
end if
if message = RIGHT_DOWN or message = RIGHT_UP then
if GetClick(3) = 1 then
SendMsg("Right mouse button clicked.")
end if
end if
if message = MIDDLE_DOWN or message = MIDDLE_UP then
if GetClick(2) = 1 then
SendMsg("Middle mouse button clicked.")
end if
end if
end procedure
procedure test_mouse()
integer pos
object mouse_event
sequence event_bits
while 1 do
mouse_event = get_mouse()
if sequence(mouse_event) then
event_bits = int_to_bits(mouse_event[1], 8)
pos = find(1, event_bits)
while pos >0 do
SendMsg(power(2, (pos-1)))
event_bits[pos] = 0
pos = find(1, event_bits)
end while
end if
key = get_key()
if key != -1 then
SendMsg(KEY_PRESS)
end if
end while
end procedure
test_mouse()
if graphics_mode(-1) then
end if
-- End of program
Listing of envrnmnt.dat
111
------=_NextPart_000_00D7_01BE5701.4ED63EC0
name="Adam W Weeden.vcf"