Hvad er der galt???
Scriptet skal bruges til at skrive til en Lpt port... har hugget scriptet fra et andet spm på eksperten:unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure Out32(PortAdresse:smallint;PortVaerdi:smallint);stdcall;export;
var
ByteVaerdi: Byte;
begin
ByteVaerdi:=Byte(PortVaerdi);
asm
push dx
mov dx,PortAdresse
mov al,ByteVaerdi
out dx,al
pop dx
end;
end;
procedure BinToParallel(bin: String);
var
tmpByte: Byte;
I: Integer;
begin
for I := length(bin) downto 1 do
if bin[I] = \' \' then
Delete(bin, I, 1);
tmpByte := (StrToIntDef(bin[1], 0) * 1) +
(StrToIntDef(bin[2], 0) * 2) +
(StrToIntDef(bin[3], 0) * 4) +
(StrToIntDef(bin[4], 0) * 8) +
(StrToIntDef(bin[5], 0) * 16) +
(StrToIntDef(bin[6], 0) * 32) +
(StrToIntDef(bin[7], 0) * 64) +
(StrToIntDef(bin[8], 0) * 128);
Out32($0378,tmpByte)
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
BinToParallel(\'01010101\');
end;
end.
AtoX