Gets a string representation of the object elements.
Overrides MfObject.ToString()
OutPutVar := instance.ToString()
Gets a string representation of the object elements
Returns string value representing object elements
Remarks
Can be overridden in derived classes.
mfLst := new MfList()
i := 0
iEnd := 10
While, (i < iEnd)
{
if (Mod(i, 2)) ; only odd numbers
{
mss := new MfString()
mss.Value := MfString.Format("String Value: '{0}", i)
mfLst.Add(mss)
}
else
{
msi := new MfInteger(i)
mfLst.Add(msi)
}
i++
}
stud1 := new Student()
stud1.Id := "RT34TTTSV"
stud1.Name := "Frank Smith"
stud1.Age := 21
stud1.HomeRoom := "English 101"
myObj := Object()
mfLst.Add(myObj)
mfLst.Add("Hello World")
mfLst.Add(557)
mfLst.Add(stud1)
strOut := mfLst.ToString()
MsgBox %strOut%
; strOut contains
/*
0: {MfInteger} 0
1: {MfString} String Value: '1
2: {MfInteger} 2
3: {MfString} String Value: '3
4: {MfInteger} 4
5: {MfString} String Value: '5
6: {MfInteger} 6
7: {MfString} String Value: '7
8: {MfInteger} 8
9: {MfString} String Value: '9
10: {Object}
11: 'Hello World'
12: '557'
13: {Student} ID:'RT34TTTSV', Name:'Frank Smith', Age:'21'
*/
Class Student extends MfObject
{
m_Id := ""
m_Name := ""
m_Age := 0
m_HomeRoom := ""
m_EnrollmentYear := 0
Id[]
{
get {
return this.m_Id
}
set {
this.m_Id := MfString.GetValue(value)
return this.m_Id
}
}
Name[]
{
get {
return this.m_Name
}
set {
this.m_Name := MfString.GetValue(value)
return this.m_Name
}
}
Age[]
{
get {
return this.m_Age
}
set {
this.m_Age := MfInteger.GetValue(value, 0)
return this.m_Age
}
}
HomeRoom[]
{
get {
return this.m_HomeRoom
}
set {
this.m_HomeRoom := MfString.GetValue(value)
return this.m_HomeRoom
}
}
EnrollmentYear[]
{
get {
return this.m_EnrollmentYear
}
set {
this.m_EnrollmentYear := MfInteger.GetValue(value, 0)
return this.m_EnrollmentYear
}
}
; Override ToString()
ToString()
{
; throw an error if called as static method
this.VerifyIsInstance(this, A_LineFile, A_LineNumber, A_ThisFunc)
return MfString.Format("ID:'{0}', Name:'{1}', Age:'{2}'", this.Id, this.Name, this.Age)
}
}