Shop OBEX P1 Docs P2 Docs Learn Events
Changing a Word into an array of Strings — Parallax Forums

Changing a Word into an array of Strings

Harry1Harry1 Posts: 29
edited 2006-11-08 22:38 in Propeller 1
So right now i have variable. which is a Word, and i wish to change it into an array of Strings in a way shown below

START

Word car := "car"

END

str[noparse][[/noparse]0] := "c"
str[noparse][[/noparse]1] := "a"
str[noparse][[/noparse]2] := "r"

Is this even possible, and if so how would i go about doing this. Any help will appreciated
Thanks ^^


·

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2006-11-08 22:29
    Harry1,

    I'm not sure exactly what you are wanting to do. When you define a string it essentially is already stored as an array. You can use the byte modifier
    to read or change individual characters.

    [b]CON[/b]
      [b]_clkmode[/b] = [b]xtal[/b]1 + [b]pll[/b]16x
      [b]_xinfreq[/b] = 5_000_000
    
    [b]OBJ[/b]
      text : "vga_text"
    
    [b]VAR[/b]
      [b]byte[/b] [b]str[/b][noparse][[/noparse]3]
    
    [b]PUB[/b] start
        [b]str[/b] := [b]string[/b]("car")                                'define 'str' variable
    
        text.start(16)                                       'Start VGA adapter
        text.out(0)
    
        text.out([b]byte[/b][noparse][[/noparse][b]str[/b]+0])                               'Display 'c'
        text.out(13)                                        
        
        text.out([b]byte[/b][noparse][[/noparse][b]str[/b]+1])                               'Display 'a'
        text.out(13)
            
        text.out([b]byte[/b][noparse][[/noparse][b]str[/b]+2])                               'Display 'r'
        text.out(13)
    
        [b]byte[/b][noparse][[/noparse][b]str[/b]+2] := "t"                                  'Change  'r' to a 't'
        text.out(13)
    
        text.out([b]byte[/b][noparse][[/noparse][b]str[/b]+0])                               'Display 'c'
        text.out(13)
        
        text.out([b]byte[/b][noparse][[/noparse][b]str[/b]+1])                               'Display 'a'
        text.out(13)
            
        text.out([b]byte[/b][noparse][[/noparse][b]str[/b]+2])                               'Display 't'
        text.out(13)
    
        [b]repeat[/b]
                           
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 11/8/2006 10:43:29 PM GMT
  • Harry1Harry1 Posts: 29
    edited 2006-11-08 22:38
    Thank YOU!!!
    that was really helpful and it works [noparse]:)[/noparse]
Sign In or Register to comment.