This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

:getvalue() method
#1
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
Reply
#2
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))
Reply
#3
(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
Reply
#4
(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.
Reply
#5
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:

Code:
object:refresh()

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 packageWink
Done is better than perfect
Reply
#6
(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:

Code:
object:refresh()

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 packageWink

Hi,
Now I better understand your aim.

B.R,
Chouaibou.
Reply


Forum Jump: