Click to See Complete Forum and Search --> : Reading 3 inputs


shaminda
March 6th, 2001, 09:06 AM
I have a program that reads and writes data to and from a parallel port. I want to read three inputs (say inputA, inputB, inputC). But I don’t know which one I will be reading first. I can read one input using the following code.

Read inputA
Do While not inputA
Read inputA
'there is more code here
Loop

How can I read 3 inputs randomly? I am thinking of using 3 Timer controls but I don’t know how. Here is an example how the function should read.

Read InputA, Read InputB, Read InputC,
Read InputB, Read InputB, Read InputA,
Read InputC, Read InputB, Read InputA,
Read InputA, Read InputA, Read InputA,

CK Dixon
March 7th, 2001, 06:14 AM
Use Multiple threads so that one thread keeps on checking one port. You will be using C++ to read from the ports anyway, aren't you.

coolbiz
March 7th, 2001, 07:05 AM
Just wondering if you can use the random number generator:


function ReadPort()
int nSelect = int((3-1+1)*rnd()-1)
select case nSelect
case 1:
Read InputA
case 2:
Read InputB
case 3:
Read InputC
end select
end function




Hope this helps :)
-Cool Bizs