Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
What are the methods of object found by grp.find method?
Code: obj = grp.find('1/1/1')
obj:write(3)
I've thinked that it has all grp methods but unfortunately not, e.g. there is no getvalue(). Maybe there is some description about its methods because when I log it I see only individual properties and no prototype's methods.
Done is better than perfect
Posts: 7839
Threads: 42
Joined: Jun 2015
Reputation:
450
You don't need getvalue() as value is already stored as obj.value
Available methods:
Code: read
write
response
update
checkwrite
checkresponse
checkupdate
You can get object's meta-table (including meta-methods) like this:
Code: log(getmetatable(obj))
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
(06.11.2018, 13:00)admin Wrote: You don't need getvalue() as value is already stored as obj.value
Available methods:
Code: read
write
response
update
checkwrite
checkresponse
checkupdate
You can get object's meta-table (including meta-methods) like this:
Code: log(getmetatable(obj))
Thanks. Yes, it is(it is something as screenshot). I've wanted stote the result of grp.find in a table and use this object later every 60s in Resident script and only use it via this methods. But while I want to use also updatetime then value update will be not enough. But I think you could add method like 'refresh' to not type again grp.find('1/1/1') but only e.g. obj.refresh()
Done is better than perfect
Posts: 71
Threads: 11
Joined: Jan 2016
Reputation:
1
(06.11.2018, 13:33)buuuudzik Wrote: (06.11.2018, 13:00)admin Wrote: You don't need getvalue() as value is already stored as obj.value
Available methods:
Code: read
write
response
update
checkwrite
checkresponse
checkupdate
You can get object's meta-table (including meta-methods) like this:
Code: log(getmetatable(obj))
Thanks. Yes, it is(it is something as screenshot). I've wanted stote the result of grp.find in a table and use this object later every 60s in Resident script and only use it via this methods. But while I want to use also updatetime then value update will be not enough. But I think you could add method like 'refresh' to not type again grp.find('1/1/1') but only e.g. obj.refresh()
Hi buuuudzik
grp.find('alias') already return a table, why you cannot just write a function to perform some tests and make changes in this table ?
I am not understanding what you need obj.refresh() as refresh also means update.
B.R
Chouaibou.
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
06.11.2018, 14:41
(This post was last modified: 06.11.2018, 14:55 by buuuudzik.)
This is an example:
Code: -- WITHOUT .refresh() is:
if not objects then
objects = {'1/1/1', '1/1/2', '1/1/3', '1/1/4'}
for i=1, #objects, 1 do objects[i] = grp.find(objects[i]) end
else
for i=1, #objects, 1 do objects[i] = grp.find(objects[i].address) end
end
-- DO SOME JOB
for i=1, #objects, 1 do log(objects[i].value) end
os.sleep(300)
-- WITH .refresh() could be:
if not objects then
objects = {'1/1/1', '1/1/2', '1/1/3', '1/1/4'}
for i=1, #objects, 1 do objects[i] = grp.find(objects[i]) end
else
for i=1, #objects, 1 do objects[i]:refresh() end -- HERE IS THE DIFFERENCE
end
-- DO SOME JOB
for i=1, #objects, 1 do log(objects[i].value) end
os.sleep(300)
I know how to deal with this situation but I would like such method:
instead of:
Code: object = grp.find(object.address)
The name is not a case, this was only a suggestion.
And I don't want add this method individually to every object but only to its prototype. And maybe not by me but by manufacturer to use it in further coding without requiring some package
Done is better than perfect
Posts: 71
Threads: 11
Joined: Jan 2016
Reputation:
1
(06.11.2018, 14:41)buuuudzik Wrote: This is an example:
Code: -- WITHOUT .refresh() is:
if not objects then
objects = {'1/1/1', '1/1/2', '1/1/3', '1/1/4'}
for i=1, #objects, 1 do objects[i] = grp.find(objects[i]) end
else
for i=1, #objects, 1 do objects[i] = grp.find(objects[i].address) end
end
-- DO SOME JOB
for i=1, #objects, 1 do log(objects[i].value) end
os.sleep(300)
-- WITH .refresh() could be:
if not objects then
objects = {'1/1/1', '1/1/2', '1/1/3', '1/1/4'}
for i=1, #objects, 1 do objects[i] = grp.find(objects[i]) end
else
for i=1, #objects, 1 do objects[i]:refresh() end -- HERE IS THE DIFFERENCE
end
-- DO SOME JOB
for i=1, #objects, 1 do log(objects[i].value) end
os.sleep(300)
I know how to deal with this situation but I would like such method:
instead of:
Code: object = grp.find(object.address)
The name is not a case, this was only a suggestion.
And I don't want add this method individually to every object but only to its prototype. And maybe not by me but by manufacturer to use it in further coding without requiring some package
Hi,
Now I better understand your aim.
B.R,
Chouaibou.
|