Indexing Virtual Ports


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2010
    Posts
    88

    Default Indexing Virtual Ports

    Hello,

    I'm trying to work on something using Darryl's VirtualPort.bas. Instead of having one macro, I've created several macros, each having their own macro name. What I was wondering (if it can be done) is this, when writing the ports, can you use an index to display the various macros.

    As an example, I have created macros pair1, pair2, pair3 and pair4. Is it possible to be able to call up the macros by entering:

    Code:
    @   OutputPort pair[index]
    and displaying them by:

    Code:
    @   WritePort  _Pattern, pair[index]
    ?

    I only ask because I have done this and get errors like:
    Found label after column 1. (pair)
    Illegal character ([)

    I'm trying to do this without having to create labels for each of these and having 4 times the code when once will do with indexing.

    The reason for this setup is for a menu I've created in my program. I'm asking it to read some data and display it on one pair of outputs. When an input is received, index is incremented by 1 and the next set of data is read and displayed on a second set of outputs. This happen two more times, so being able to index the macros would be ideal. Do you think this is possible?

    Thanks in advance,
    Tony

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Nope, can't do that.
    But you could do something similar wth SELECT.

    Code:
    SELECT CASE Index
        CASE 0 : @   OutputPort pair0
        CASE 1 : @   OutputPort pair1
        CASE 2 : @   OutputPort pair2
        CASE 3 : @   OutputPort pair3
    END SELECT
    
    ;-------------------------------
    
    SELECT CASE Index
        CASE 0 : @   WritePort  _Pattern, pair0
        CASE 1 : @   WritePort  _Pattern, pair1
        CASE 2 : @   WritePort  _Pattern, pair2
        CASE 3 : @   WritePort  _Pattern, pair3
    END SELECT
    DT

  3. #3
    Join Date
    Jan 2010
    Posts
    88


    Did you find this post helpful? Yes | No

    Default

    How come it's never so obvious when you're trying to figure it out yourself? Thanks again Darrel.

Similar Threads

  1. Replies: 4
    Last Post: - 17th April 2009, 08:56
  2. Indexer not indexing...a basic PBP problem??
    By jellis00 in forum General
    Replies: 8
    Last Post: - 24th March 2009, 16:53
  3. Question on IO ports
    By studysession in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th February 2009, 18:10
  4. 20 Digit Virtual LED Counter
    By T.Jackson in forum Code Examples
    Replies: 9
    Last Post: - 19th November 2007, 05:02
  5. Replies: 1
    Last Post: - 29th September 2007, 18:05

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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