The new function below doesn t work if Obj is local. If I remove it from /local it works. So what to do to make it work with a local Obj thanks ? Sure not hard for you.
Person: make object! [
Person: func[FirstName LastName][
Self/FirstName: FirstName
Self/LastName: LastName
Print Self/FirstName
Print Self/LastName
]
FirstName: ""
LastName: ""
]
new: func[Class [Object!] Param-Block [block!] /local Obj][
Constructor: to-word pick pick Class 1 2
Obj: Make Class []
params: copy ""
foreach param Param-Block [
if string? param [
param: rejoin [{"} param {"}]
]
append params param
append params " "
]
do rejoin [{do get in Obj Constructor} { } params]
Obj
]
;FOR TEST
John: new Person["John" "Doe"]
Would give
>> probe John
make object! [
Person: func [FirstName LastName][
Self/FirstName: FirstName
Self/LastName: LastName
Print Self/FirstName
Print Self/LastName
]
FirstName: ""
LastName: ""
]
>>
That is FirstName and LastName are "" instead of "John" "Doe"