PORT LPT1

Sorry my english is poor.
I need to read the paralel port, there are four input.
are there a procedure? ..in delphi ofcourse.
chiroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fatman121898Commented:
No, there is no array such as Port[] in good old Turbo Pascal.

The easiest way is to use assembler functions as follows:

function ReadPort(PortNum:Word):Byte;
  begin
    asm
      mov dx, PortNum
      in al, dx
      mov Result, al
    end;
  end;

procedure WritePort(PortNum:Word,Data:Byte);
  begin
    asm
      mov dx, PortNum
      mov al, Data
      out dx, al
    end;
  end;


You should use this stuff in next manner:

var A, B:Byte;...
....
begin
  A:=ReadPort($37f); //to read data from port
  WritePort($37f,B); //to write data to port
....
end.

Caution! This will not work with WindowsNT because of strong system
control over ports, but with Windows95/98 it works fine.



Jo.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fatman121898Commented:
If you want to use parallel port as data input, there may be some restrictions because of some IO cards  do not support bidirectional data lines.
In this case you may use some of sinal pins of parallel port. If so, you should use IO card STATUS register instead of DATA register, but there are only 4 input signal pins, so you can read 4 bit portions at time.

Jo.
0
Fatman121898Commented:
Knock, knock, is there anybody?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.