211 of 323
ZBasic System Library 201 ZX Microcontroller Family PortBit Type Function returning Byte Invocation PortBit(portIdx, bitIdx) PortBit(pin) Parameter Method Type Description portIdx ByVal integral The I/O port designator (A=0, B=1, etc.) bitIdx ByVal integral The bit designator (0-7) pin ByVal integral A pin number Discussion This function returns a composite value that describes a specific bit in a specific I/O port. The fields of the Byte value are as shown in the table below. Bit(s) Description 7 Always 1 6-3 The I/O port designator (A=0, B=1, etc.) 2-0 The bit designator (0-7) When invoked in the first form with the parameter values 2 and 6 (representing Port C, bit 6) the return value will have the bit pattern &B10010110. The second form of invocation converts a physical pin number to the composite value representing the port and bit corresponding to that pin. When passed an invalid pin, the return value is zero. Values returned by the PortBit() function may be used anywhere that a pin number may be used, e.g. as the first parameter to PutPin(). The primary advantage to using the composite port/bit designator is that the same value may be used unchanged on any ZX device. Note that the special port/bit designators like C.2 are converted by the compiler to the same type of composite port/bit designator described here if the compiler directive Option PortPinEncoding On is specified. Compatibility This function is not available in BasicX compatibility mode.