Is there any way to access property from another string?

Class A Extends %Persistent

{

Property Doctor1 As %Library.String;

Property Doctor2 As %Library.String;

Property Doctor3 As %Library.String;

}

I know my solution is wrong, but if i want to access A.Doctor1, can I  get a way like 

s count=1

s DoctorName="Doctor"_""_count

A.DoctorName="doctor1"

  • 0
  • 0
  • 72
  • 1
  • 1

Answers

Do you want to access properties without coding them?

Use $property for that:

set obj = ##class(A).%New()

for i=1:1:3 {

   set $property(obj, "Doctor" _ i) = ##class(%PopulateUtils).Name()

}

zwrite obj