Shop OBEX P1 Docs P2 Docs Learn Events
struct command? — Parallax Forums

struct command?

ohVaNiLLaGoRiLLaohVaNiLLaGoRiLLa Posts: 33
edited 2014-01-28 10:48 in Propeller 1
is there anything in the propeller language that is like struct in C?

for example if you wanted to put numbers for an rgb color you could do something like this

struct RGB {  byte r;  byte g;  byte b;};


and then you could put values in for each r,g, and b






variable = (RGB){255, 0, 255};

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-01-28 10:48
    There's nothing like that in Spin. However, with the use of defined constants, you could use arrays, viz:
    [b]CON[/b]
    
      RED = 0
      GRN = 1
      BLU = 2
    
    [b]VAR[/b]
    
      [b]byte[/b] Color[3]
    
    [b]PUB[/b] start
    
      Color[RED] := 255
      Color[GRN] := 0
      Color[BLU] := 128
    
      ... or ...
    
      [b]bytemove[/b](@Color, string(255, 0, 128), 3)
    

    -Phil
Sign In or Register to comment.