Logic Machine Forum
:getvalue() method - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: :getvalue() method (/showthread.php?tid=1697)



:getvalue() method - buuuudzik - 06.11.2018

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.


RE: :getvalue() method - admin - 06.11.2018

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))



RE: :getvalue() method - buuuudzik - 06.11.2018

(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()


RE: :getvalue() method - CHOUAIBOU - 06.11.2018

(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.


RE: :getvalue() method - buuuudzik - 06.11.2018

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


RE: :getvalue() method - CHOUAIBOU - 06.11.2018

(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.