Skip to content

String vs. Symbol vs. InstanceName #16

@gitttt

Description

@gitttt

The below code outputs:

---
/path/to/binary
<class 'str'>
---
/path2/to/binary
<class 'clips.common.Symbol'>
---
/path2/to/binary
<class 'str'>

Is this how it is supposed to be? Isn't there a type InstanceName? How can I know from python if I have (slotname [a_string])
or

(slotname "a_string")

?

import clips


env = clips.Environment()


binary_class_string = """
(defclass clips_BINARY (is-a USER)
  (slot path)
  (slot path2)
  (slot path3))
"""
env.build(binary_class_string)

network_function_class_string = """
(defclass clips_NETWORK_FUNCTION (is-a USER)
  (slot binary)
  (slot start_address))
"""
env.build(network_function_class_string)


make_binary_instance_string = """
(make-instance UniversalSample.exe of clips_BINARY (path [/path/to/binary]) (path2 /path2/to/binary) (path3 "/path2/to/binary"))
"""

env.eval(make_binary_instance_string)
instance_just_created = env.find_instance("UniversalSample.exe")
print(instance_just_created)

make_network_function_instance_string = """
(make-instance my_func of clips_NETWORK_FUNCTION (binary [UniversalSample.exe])(start_address 4278884))
"""

env.eval(make_network_function_instance_string)
instance_just_created = env.find_instance("my_func")
print(instance_just_created)
print(type(instance_just_created["binary"]))
linked_instance = env.find_instance(instance_just_created["binary"])
print(linked_instance)

print("---")
print(linked_instance['path'])
print(type(linked_instance['path']))

print("---")
print(linked_instance['path2'])
print(type(linked_instance['path2']))

print("---")
print(linked_instance['path3'])
print(type(linked_instance['path3']))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions