CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 1999
    Location
    Ohio, USA
    Posts
    163

    Reading 3 inputs

    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,








  2. #2
    Join Date
    Jun 2000
    Location
    Nepal
    Posts
    108

    Re: Reading 3 inputs

    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.


  3. #3
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: Reading 3 inputs

    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

    Good Luck,
    -Cool Bizs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured