Written by

Question Ogura Yui · Nov 20, 2018

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"

Comments

Eduard Lebedyuk · Nov 20, 2018

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
0
Ogura Yui  Nov 21, 2018 to Eduard Lebedyuk

Very convenient, thank you !!

0