instead of "same?" use "equal?" and use "#" in
single character tests.  This works:
ms: 0
str: "my+name+is+tim"

forall str
[
  if equal? first str #"m"
    [ms: ms + 1]
  if equal? first str #"+"
    [change str #" "]
]
print ["ms: " ms]
str: head str
print str

>>> <[EMAIL PROTECTED]> 04/05 12:36 AM >>>
Hello All:
I want to search each element in a string.
I want to count occurances of some elements
and change other elements

;example count every occurance of 'm'
;  change every occurance of '+' to ' '
ms: 0
str: "my+name+is+tim"
pairs: 0
forall str
[
  if same? first str "m"
    [ms: ms+ 1]
  if same? first str "+"
    [change str #" "]
]
print ["ms: " ms]
str: head str
print str

;The preceding code obviously doesn't work. 
what am I doing wrong.
TIA
Tim



Reply via email to