hello every body
i have a simple script for getting environments data. when i run script from terminal it gets full data but when i run it from script sections it does not get data.
look at log
i first run script and value is only id
second time i ran it from terminal command and i get name and value for it
i need global variable data for scripting
@ak313 - RoS has an undocumented flaw when running the terminal in interactive mode that allows indexing objects with regular numbers. When a script is run in ‘batch mode’ a true index type is required by using [get …] resulting in something like ‘*1’. You can also test this by entering ‘*1’ in an interactive terminal,
EDIT: [get …] as the statement @Amm0 demonstrated in the post above. You can show the index with ‘:put [find name=“myvarname”]’
It’s not a “flaw” in scripting. If you want to see the .id, use “print show-ids”. For interactive CLI use, the “always sequential” numbering of a “print” makes sense IMO.
i.e. * numbers (“.id”) are immutable…if one get’s deleted the .id # is not reused - which makes them safe for non-interactive scripts. But for interactive CLI use… the first result of a “print” is always 1, 2nd is always 2, etc., which includes if “where” is used to filter results. And with a lot of add/deletes, the * .id can get big and be non-sequential.
Yeah, you’re probably correct from a purely technical standpoint, but since this isn’t the first time someone has encountered this issue, I still consider it a flaw.
If the interactive terminal were behaving differently, we wouldn’t be having this discussion IMO.
thank you
i do not know names so
i reached to this solution:
:foreach E in=[/system script environment find] do={:log info $E;:local name [ /system/script/environment get [find .id=$E ]];:log info $name;}
Since you already have the “.id” from the :foreach on [find], you do not need the 2nd [find] since “get” works with the .id.
:foreach E in=[/system script environment find] do={:log info $E;:local name [ /system/script/environment get $E ];:log info $name;}
@Larsa is right – it is a bit confusing. But issue is the numbers shown from /system/script/env/print (or any other “print”) are NOT usable in a “get”, but the “.id” * numbers are. And [find .id=$E] is same $E since [find] returns an .id (or list/array of .id’s) already.