Shop OBEX P1 Docs P2 Docs Learn Events
Syntax for testing an array of variables? — Parallax Forums

Syntax for testing an array of variables?

coryco2coryco2 Posts: 107
edited 2011-03-31 04:37 in Propeller 1
Is there any syntax in Spin to test an array of variables, for example in an IF statement? Something like this:
VAR
BYTE variable[4]

PUB
IF variable == [1, 1, 1, 1]
someMethod

...instead of

IF variable[1] == 1 AND variable[2] ==1 AND variable[3]==1 AND variable[4]==1
someMethod

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-03-31 04:37
    In general: NO

    In special cases: Yes
    For example:
    .. if you want to compare an array of 4 bytes you could simply do a long compare instead. (of course you have to assure that the bytes are long-alligned)

    .. if you can assure that 0 is not a valid value of each array-element, you can use string compare function.
Sign In or Register to comment.