How does or should "Is Among" work ?
Posted: Wed Feb 01, 2017 1:16 pm
Hi I am confused by the use of "item" and "items". Specifically I have a field named ColourCodes that holds the following data, these are todo priorities at the beginning of the line followed by a comma and then a named colour :
Normal,LightPink2
Priority,MediumSeaGreen
Note,LightGreen
High,LightGray
Completed,LightSalmon
Hold,LightPink2
I have a handler that wishes to add new priorities to my list with a default colour of "black". First it has to check that the priority does not already have an entry. Using "Hold" as an example I have tried various constructs using "is among" and its various "chunk types" e.g.
It appears that the "is among" just does not handle the comma in the rows of data which seems a little odd given that reading each line and then addressing "item 1" of line works as expected.
I have attached a small stack file and would appreciate any comments as to the logic of "is among"
best wishes
Simon K
Normal,LightPink2
Priority,MediumSeaGreen
Note,LightGreen
High,LightGray
Completed,LightSalmon
Hold,LightPink2
I have a handler that wishes to add new priorities to my list with a default colour of "black". First it has to check that the priority does not already have an entry. Using "Hold" as an example I have tried various constructs using "is among" and its various "chunk types" e.g.
Code: Select all
on mouseUp
set the itemdel to comma
If "Hold" is among the items of Field "ColourCodes" then
answer "Found in field"
else
answer "Not found in field"
end if
put Field "ColourCodes" into tMystring
If "Hold" is among the items of tMyString then
answer "Found in string"
else
answer "Not found in string"
end if
replace CR with " <NL> " in tMyString
If "Hold" is among the items of tMyString then
answer "Found in modified string"
else
answer "Not found in modified string"
end if
end mouseUp
I have attached a small stack file and would appreciate any comments as to the logic of "is among"
best wishes
Simon K