+ Added SetToString example

This commit is contained in:
michael 2001-09-09 09:22:06 +00:00
parent e8c8f8785a
commit e111767081
3 changed files with 35 additions and 3 deletions

View File

@ -33,9 +33,7 @@ endif
.PHONY: all tex clean
OBJECTS=rttiobj trtti1 trtti2 trtti3 ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 \
ex10 ex11 ex12 ex13
# ex14
# ex15 ex16
ex10 ex11 ex12 ex13 ex14 ex15 ex16 ex17 ex18
TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))

View File

@ -24,3 +24,4 @@ ex14.pp This program demonstrates the FindPropInfo function
ex15.pp This program demonstrates the GetInt64Prop function
ex16.pp This program demonstrates the PropIsType function
ex17.pp This program demonstrates the PropType function
ex18.pp This program demonstrates the SetToString function

33
docs/typinfex/ex18.pp Normal file
View File

@ -0,0 +1,33 @@
program example18;
{ This program demonstrates the SetToString function }
{$mode objfpc}
uses rttiobj,typinfo;
Var
O : TMyTestObject;
PI : PPropInfo;
I : longint;
begin
O:=TMyTestObject.Create;
PI:=GetPropInfo(O,'SetField');
O.SetField:=[mefirst,meSecond,meThird];
I:=GetOrdProp(O,PI);
Writeln('Set property to string : ');
Writeln('Value : ',SetToString(PI,I,False));
O.SetField:=[mefirst,meSecond];
I:=GetOrdProp(O,PI);
Writeln('Value : ',SetToString(PI,I,True));
I:=StringToSet(PI,'mefirst');
SetOrdProp(O,PI,I);
I:=GetOrdProp(O,PI);
Writeln('Value : ',SetToString(PI,I,False));
I:=StringToSet(PI,'[mesecond,methird]');
SetOrdProp(O,PI,I);
I:=GetOrdProp(O,PI);
Writeln('Value : ',SetToString(PI,I,True));
O.Free;
end.