💾 Archived View for going-flying.com › files › LED.PAS captured on 2020-10-31 at 00:54:58.

View Raw

More Information

⬅️ Previous capture (2020-09-24)

-=-=-=-=-=-=-

Program CgiLights;
Uses CRT,strnttt5;

Const Address : word = $378;
    	mver : string = '1';
        minver : string ='0b3c';

type statrec = record
	Led1Toggled:boolean;
	Led2Toggled:boolean;
        Led3Toggled:boolean;
	End;

var inchar:char;
    Status:statrec;
    CommandProcessed: boolean;
    tf:text;
    counts:string;count:longint;


Procedure IncrementCounter;
Var
f:text;
Begin
Assign(f,'count.txt');

Reset(f);
readln(f,counts);
close(f);
count:=str_to_int(counts);
inc(count);
rewrite(f);
writeln(f,count);
close(f);
end;


Procedure SetLed1(Status:boolean);
Begin
Case Port[Address] of
	$00 : If Status then Port[Address]:=$01;
        $02 : If Status then Port[Address]:=$03;
        $04 : If Status then Port[Address]:=$05;
        $06 : If Status then Port[Address]:=$07;
        $01 : If Not Status Then Port[Address]:=$00;
        $03 : If Not Status Then Port[Address]:=$02;
        $07 : If Not Status Then Port[Address]:=$06;
End; {case}
End; {proc}


Procedure SetLed2(Status:boolean);
Begin
Case Port[Address] of
	$00 : If Status then Port[Address]:=$02;
        $01 : If Status then Port[Address]:=$03;
        $04 : If Status then Port[Address]:=$06;
        $05 : If Status then Port[Address]:=$07;
        $02 : If Not Status Then Port[Address]:=$00;
        $03 : If Not Status Then Port[Address]:=$01;
        $06 : If Not Status Then Port[Address]:=$04;
        $07 : If Not Status Then Port[Address]:=$05;
End; {case}
End; {proc}


Procedure SetLed3(Status:boolean);
Begin
Case Port[Address] of
	$00 : If Status then Port[Address]:=$04;
        $01 : If Status then Port[Address]:=$05;
        $02 : If Status then Port[Address]:=$06;
        $03 : If Status then Port[Address]:=$07;
        $04 : If Not Status Then Port[Address]:=$00;
        $05 : If Not Status Then Port[Address]:=$01;
        $06 : If Not Status Then Port[Address]:=$02;
        $07 : If Not Status Then Port[Address]:=$03;
End; {case}
End; {proc}

Function GetLed1:boolean;
Begin
        GetLed1:=False;
        if Port[Address]=$01 then GetLed1:=true;
        if Port[Address]=$03 then GetLed1:=true;
	if Port[Address]=$05 then GetLed1:=true;
        if Port[Address]=$07 then GetLed1:=true;
End; {proc}

Function GetLed2:boolean;
Begin
        GetLed2:=False;
        if Port[Address]=$02 then GetLed2:=true;
        if Port[Address]=$03 then GetLed2:=true;
	if Port[Address]=$06 then GetLed2:=true;
        if Port[Address]=$07 then GetLed2:=true;
End; {proc}

Function GetLed3:boolean;
Begin
        GetLed3:=False;
        if Port[Address]=$04 then GetLed3:=true;
        if Port[Address]=$05 then GetLed3:=true;
	if Port[Address]=$06 then GetLed3:=true;
        if Port[Address]=$07 then GetLed3:=true;
End; {proc}

Procedure WriteWWWInterface;
var
f:text;
Begin
        Assign(f,'led.txt');
        Rewrite(f);
	Writeln(f,'Content-Type: text/html');
        Writeln(f,'');
        Writeln(f,'<HTML><HEAD><TITLE>The Amazing Led Thing</TITLE></HEAD><BODY><CENTER>');
        Writeln(f,'<IMG SRC="/led/header.jpg" alt="[Matt''s LED Script]"><BR>');
        Writeln(f,'<A HREF="/cgi-bin/led/led.bat?info">Information</A><BR>');
        If CommandProcessed Then
        	Begin
			Writeln(f,'<TABLE BORDER=1><TD>');
                        Writeln(f,'<B><CENTER>- - - - -Status Window- - - - -</B><BR>');
                        If Status.Led1Toggled Then Writeln(f,'Toggled LED 1!');
                        If Status.Led2Toggled Then Writeln(f,'Toggled LED 2!');
			If Status.Led3Toggled Then Writeln(f,'Toggled LED 3!');
                        Writeln(f,'</TD></TABLE><BR><HR>');
                End;
        Writeln(f,'Light Emitting Diode (LED) Status:<BR>');
	If GetLed1 Then Writeln(f,'LED 1: On') Else Writeln(f,'LED 1: Off');
        Writeln(f,'<BR>');
        If GetLed2 Then Writeln(f,'LED 2: On') Else Writeln(f,'LED 2: Off');
        Writeln(f,'<BR>');
        If GetLed3 Then Writeln(f,'LED 3: On') Else Writeln(f,'LED 3: Off');
        Writeln(f,'<BR>');
        Writeln(f,'Control Center:<HR Width="50%">');
        Writeln(f,'<A HREF="/cgi-bin/led/led.bat?toggle1">Toggle LED 1</A> ');
        Writeln(f,'<A HREF="/cgi-bin/led/led.bat?toggle2">Toggle LED 2</A> ');
        Writeln(f,'<A HREF="/cgi-bin/led/led.bat?toggle3">Toggle LED 3</A><BR>');
        Writeln(f,'There have been '+counts+'hits.<BR><HR><I></CENTER>lights'+mver+'.'+minver+'');
        Writeln(f,'<CENTER>This Project Is (c) 1998 <a href="mailto:selfdestruct@innocent.com">Matthew Ernisse</a>');
	Writeln(f,' All Rights Reserved.<BR>');
        Writeln(f,'Hosted By <a href="http://www.infinitycomputers.dyn.ml.org/">Infinity Computers Of Rochester, Ny.</A><BR>');
        Writeln(f,'</CENTER></BODY>');
	Close(f);
End;

Begin
{Port[Address]:=$00;
$00 = 1=0,2=0,3=0
$01 = 1=1,2=0,3=0
$02 = 1=0,2=1,3=0
$03 = 1=1,2=1,3=0
$04 = 1=0,2=0,3=1
$05 = 1=1,2=0,3=1
$06 = 1=0,2=1,3=1
$07 = 1=1,2=1,3=1}
        IncrementCounter;
	Status.Led1Toggled:=false;
        Status.Led2Toggled:=false;
        Status.Led3Toggled:=false;
        CommandProcessed:=false;
	If ParamStr(1)='info' then
        Begin
        	assign(tf,'led.txt');
                rewrite(tf);
        	Writeln(tf,'Content-Type: text/html');
                Writeln(tf,'');
                Writeln(tf,'<HTML><HEAD><TITLE>The Led Thingy!  Info</TITLE><BODY>');
                Writeln(tf,'This Is a Script to play with the 2 led''s plugged into my');
                Writeln(tf,'parallel port.  Play with it.');
        	Close(tf);
        	Halt(0);
        End;
        If ParamStr(1)='toggle1' then
        	Begin
                        CommandProcessed:=true;
                        Status.Led1Toggled:=true;
                        SetLed1(Not GetLed1);
                End;

        If ParamStr(1)='toggle2' then
        	Begin
                        CommandProcessed:=true;
                        Status.Led2Toggled:=true;
                        SetLed2(Not GetLed2);
                End;
        If ParamStr(1)='toggle3' then
        	Begin
                        CommandProcessed:=true;
                        Status.Led3Toggled:=true;
                        SetLed3(Not GetLed3);
                End;

	WriteWWWInterface;
End.