From OpenCog
Jump to: navigation, search

The StringValue is a kind of value. It allows for the specification of a vector of strings.

Example usage:

(StringValue "a" "bb" "ccc")

creates a value. To associate it with an atom, say:

(cog-set-value! (Concept "abc") (Predicate "key")
    (StringValue "a" "bb" "ccc"))

The above sets the value on ConceptNode "abc", placing it at the key of PredicateNode "key". To fetch it, say

 (cog-value (Concept "abc") (Predicate "key"))

To get the actual strings back, use either cog-value->list to get the whole list, or use cog-value-ref to get the n'th element. Example:

(cog-value->list (cog-value (Concept "abc") (Predicate "key")))

(cog-value-ref (cog-value (Concept "abc") (Predicate "key")) 2)