PDA

View Full Version : Indexing Virtual Ports



ERMEGM
- 14th February 2010, 05:15
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:


@ OutputPort pair[index]

and displaying them by:


@ 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

Darrel Taylor
- 14th February 2010, 09:22
Nope, can't do that.
But you could do something similar wth SELECT.


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

ERMEGM
- 15th February 2010, 03:44
How come it's never so obvious when you're trying to figure it out yourself? :) Thanks again Darrel.