View Full Version : Changing a Word into an array of Strings
Harry1
11-09-2006, 04:32 AM
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[0] := "c"
str[1] := "a"
str[2] := "r"
Is this even possible, and if so how would i go about doing this. Any help will appreciated
Thanks ^^
·
Beau Schwabe (Parallax)
11-09-2006, 05:29 AM
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.
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
text : "vga_text"
VAR
byte str[3]
PUB start
str := string("car") 'define 'str' variable
text.start(16) 'Start VGA adapter
text.out(0)
text.out(byte[str+0]) 'Display 'c'
text.out(13)
text.out(byte[str+1]) 'Display 'a'
text.out(13)
text.out(byte[str+2]) 'Display 'r'
text.out(13)
byte[str+2] := "t" 'Change 'r' to a 't'
text.out(13)
text.out(byte[str+0]) 'Display 'c'
text.out(13)
text.out(byte[str+1]) 'Display 'a'
text.out(13)
text.out(byte[str+2]) 'Display 't'
text.out(13)
repeat
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 11/8/2006 10:43:29 PM GMT
Harry1
11-09-2006, 05:38 AM
Thank YOU!!!
that was really helpful and it works :)