Solved

# LPT Port ?

Posted on 2002-07-08
532 Views
Hi.

I need to read bits from my printer port.
I use DLPORTIO.dll to write the bits.

Now i need to read the bits that are active.

Eg if i write: 1001110

Then i want to be able to close my prog, and read the current status of the port, and actually get back the: 1001110

If u use the read button in the demo, it gets back the value in hex, and i need to get it back the other way.

Can anyone help?

Thanks
0
Question by:Dennis9

LVL 5

Expert Comment

ID: 7138234
If you can get the value back in hex then you can convert the hex value back to its binary form with a function like below:

function HexToBin(Hex : string) : string;
const
BCD : array [0..15] of string = ('0000', '0001', '0010', '0011', '0100',
'0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101',
'1110', '1111');
var
I : integer;
begin
for I := Length(Hex) downto 1 do
Result := BCD[StrToInt('\$' + Hex[I])] + Result;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(HexToBin('4E'));
end;

Cheers,

Alan
0

LVL 1

Author Comment

ID: 7139052
its 8 bit result i want eg: 10101101
0

LVL 5

Expert Comment

ID: 7139232
I've downloaded and had a quick look at the DLPORTIO.dll and assume you are using the following function to interface between your prog and the driver to read an 8 bit result (or a byte):

function DlPortReadPortUchar(Port : LongInt) : Byte; stdcall;

As this returns a byte then you can convert straight from a byte to its binary form with the function IntToBin() which is implemented in the IdGlobal unit.
0

LVL 1

Accepted Solution

Dennis9 earned 0 total points
ID: 7164478
I found another way around, i thought i could write bits, but i need to write hex decimals now its all working

Thanks anyways
0

Expert Comment

ID: 9343093
Dennis9:
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

LVL 5

Expert Comment

ID: 9460301
Dennis9,
No comment has been added lately (18 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Accept alanwhincup's answer http:#7139232 and Refund

-- Please DO NOT accept this comment as an answer ! --

Thanks,

anAKiN
EE Cleanup Volunteer
0

## Featured Post

### Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

#### Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!