Logic Machine Forum
Add objects, delete objects automatically using the command line! - 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: Add objects, delete objects automatically using the command line! (/showthread.php?tid=174)



Add objects, delete objects automatically using the command line! - phongvucba - 29.12.2015

Dear all!
can you help me.
I would like to add and delete objects automatically using the command line..
So,,,What should I do?
This example is finding an object and returns a value.
grp.find('add...')
if I want to find many objects at once, I have to do?
thank all!


RE: Add objects, delete objects automatically using the command line! - admin - 29.12.2015

To create objects:
http://openrb.com/docs/lua.htm#grp.create

To delete objects use this function:
Code:
-- you can delete by group address
grp.delete('1/1/1')
-- or delete by object name
grp.delete('My object name')
You can find multiple objects either by tag or data type, look for grp.tag and grp.dpt in the docs.


RE: Add objects, delete objects automatically using the command line! - phongvucba - 01.01.2016

(29.12.2015, 17:06)admin Wrote: To create objects:
http://openrb.com/docs/lua.htm#grp.create

To delete objects use this function:
Code:
-- you can delete by group address
grp.delete('1/1/1')
-- or delete by object name
grp.delete('My object name')
You can find multiple objects either by tag  or data type, look for grp.tag and grp.dpt in the docs.

thank admin!
but it does not work. I write
-========================
address = grp.create({
  datatype = dt.float16,
  address = '4/4/123',
  name = 'My first object',
  comment = 'This is my new object',
  units = 'W',
  tags = { 'My tag A', 'My tag B' },
})

grp.delete('4/4/133')
====================
and it is not self-created address 4/4/123
and delete the address 4/4/132
Was I write wrong!

and you want to interrupt a loop, to get out before the end of the loop /

Command line can do it ....
people help me !!!! Undecided   thank so much !!  Heart Heart Heart Heart



RE: Add objects, delete objects automatically using the command line! - admin - 01.01.2016

Which firmware version are you running? grp.create and grp.delete are only available in latest firmware. You should also check the error log, there might be an error somewhere else in the script.


RE: Add objects, delete objects automatically using the command line! - Pawel - 01.01.2016

Can you give some usefull example of creating or deleting objects by script? I dont have any idea how someone can use this feature


RE: Add objects, delete objects automatically using the command line! - phongvucba - 02.01.2016

(01.01.2016, 10:49)admin Wrote: Which firmware version are you running? grp.create and grp.delete are only available in latest firmware. You should also check the error log, there might be an error somewhere else in the script.
Thank admin,! May be you right!. Firmware version i running is 2014.11.27. 

and i want to interrupt a loop, to get out before the end of the loop.  What do you do?
Ex...in C and C# we have Break and Continue.
Please, help me..thank so much.admin and everyone!
I want use.


RE: Add objects, delete objects automatically using the command line! - admin - 04.01.2016

Lua does not have continue, but it does have break:
http://www.lua.org/pil/4.4.html


RE: Add objects, delete objects automatically using the command line! - phongvucba - 09.01.2016

[quote pid='733' dateline='1451892112']
adminLua does not have continue, but it does have break:
http://www.lua.org/pil/4.4.html
[/quote]

thank all!
 thank admin!
Heart Heart Heart