DXL simple attribute return - ibm-doors

i am new to DXL.
What i am trying to achieve:
I would like to create a DXL column in a module which displays the object's ForeignID plus a prefix.
What i tried:
Module m = current
Object o
for o in m do {
string s = o."ForeignID"
displayRich("Prefix " s)
}
but this only results in the entire list Prefix+ForeignID of all module's objects within each cell of the DXL column.
What do i need to change so every object will only show it's own Prefix+ForeignID within the DXL cell.
Thanks in advance for your help

You can get some information here: https://www.ibm.com/docs/en/ermd/9.7.1?topic=definitions-dxl-attributes-layout-dxl-columns. Also check the DXL reference which is linked on that page
The code in DXL Layout columns is executed for each Object, there is a variable called "obj", which points to the Object which is being calculated at the moment (N.B. that is NOT the "current" Object, which is the Object that the user has clicked on).
Your code would simply be
string s = obj."ForeignID"
displayRich("Prefix " s)
or as a one-liner
displayRich("Prefix " obj."ForeignID" "")
(in this case, display would suffice. displayRich is only need when you have RTF (formatted) text, like the one in "Object Text".)

Related

dart removeWhere() - where does the data go?

I am trying to write a function in dart that takes a string that has some words that be begin with a "#" character and split it into two sets. One that contains string with only the "#" character and one with no "#" characters.
There are some obvious ways i could do this with a for loop, but want to use these fancy list processing functions (what are these called exactly?) like where() forEach().
so here is my attempt.
void main() {
String inputText = "Hello world. #hithere";
inputText.split(" ").where((element) => element.startsWith("#"))
.forEach((item) {
print(item);
});
inputText.split(" ").removeWhere((element) => element.startsWith("#"));
print(inputText);
}
Here is the output of the program:
#hithere
Hello world. #hithere
the first part works as expected, but the second part i expected the removeWhere would remove the element #hithere from my list....
but this this didnt happen.
So my question is this. Did the removeWhere() method remove this element correctly? If so where is the list that has this element removed? How do i get access to it?
my explanation of what happend is that the split(" ") method created a List and the removeWhere() method operated on this List and removed the element i told it to... but what i dont understand is how i can get access to this list? where does this list exist?
what i was think i should do is something like this:
inputText.split(" ").removeWhere((element) => element.startsWith("#")).join();
I was hoping that i could take the List with the removed elements and join() them back into a string... but since the removeWhere() method returns void.. i have no idea where the list that has removed elements exists?

Lua puts of variable name instead of variable value in table

Hello guys i am trying to add Divisions to a game but there is a problem with tables, do you guys know how to solve this?
local divisonName = result3[i].name
print(divisonName)
ESX.Divisions[result3[i].owner].divisonName = {}
it's the code it should get division name and create a table with that like this (we assume divisonName gonna return swat for example):
["police"] = {
["swat"] = {
},
},
but instead of putting division name as SWAT it will put divisionName variable
i already print that divisionName variable and console return me SWAT so everything is fine with logic and value of variable but i guess there it's syntax issue i am not sure!
Console Debug image
Note that in Lua the construct some_table.field is a syntactic sugar for some_table["field"]. Whatever is written after the dot will be treated as a string key.
In your case, to index by the value stored in the variable, you need to write ESX.Divisions[result3[i].owner][divisonName], and not as .divisionName.

How can I insert objects into a DOORS module via DXL?

I read through the DOORS Reference Manual but couldn't find a simple insert method. I'm looking to insert an object, which was created within my DXL script, into a module.
I was hoping to find something intuitive like
insert_object_after(Module m, Object o, string object_identifier)
which would scan the module for the specified object identifier and insert the object after finding that identifier. Does such a function exist? If not how could I go about performing the action I've described?
Some basic example code would be awesome.
Chapter „Object management“. Use one of the commands
Object create(Module m)
Object create(Object o)
Object create(after(Object o))
Object create(before(Object o))
Object create(below(Object o))
Object create(first(below(Object o)))
Object create(last(below(Object o)))
For these functions, you need a variable of type Object. There are several ways to fill such a variable, look at the chapters „Finding objects“ and „Navigation from an object“. Probably the easiest way would be to use the function Object object(int absno[,Module m]) (with absno being the absolute number of the „source“ object. But beware that object only works if the current filter allows to navigate to this object, so, if the function "Go To“ from the menu works in your current view with your source object, then object should work as well

Adding a Value to Collection Items

I want to load data from many files. Each file is named with a date and I need to inject this date to each of the fetched Entries of my file.
I know I could do this with an foreach - loop before inserting the data into the collection, but I think there should be a better solution.
Content of one file
[{"price":"95,34","isin":"FR0000120073"},{"price":"113,475","isin":"CA13645T1003"}]
The Code I use to move the data into a collection.
$collection= collect(json_decode(File::get($file)));
I tried for example the "map" method, however I don't know how to pass an additional variable to the anonymous function.
The content of my collection should look like this:
[{"price":"95,34","isin":"FR0000120073","date":"2016-06-23"},{"price":"113,475","isin":"CA13645T1003","date":"2016-06-23"}]
Is there any simple solution using the collections or do I have to use a foreach-loop?
May be this will help
$collection = collect(json_decode(File::get($file)));
$collection = $collection->each(function ($item, $key) {
//First iteration of $item will be {"price":"95,34","isin":"FR0000120073"}
$item->date = "2016-06-23"; //Insert key, value pair to the collection
});

How does this Linked List example in Lua actually work?

I'm in the process of relearning programming after several years and I'm currently focusing on both C# and Lua. The book I'm using for Lua has an example for a Linked List, but I'm having a difficult time understanding exactly how it's working.
list = nil
for line in io.lines() do
list = {next = list, value = line}
end
If i'm reading this right
it's creating a new table
assigning list to that table, setting the "next" key/identifier (correct terminology?) to point to the list (which is still nil at the point of the first created table)
then setting the "value" key/identifier to be whatever was read in
then the "list" is now actually pointing to the newly created table
Then on the next run through of the loop
creating the next table
setting the "next" key/identifier to point to the list (which is now pointing to the previously created table)
then setting the "value" key/identifier to be whatever was read in
then the "list" is now actually pointing to the newly created table...again
I just wanted to be sure I understood exactly how this was working as it seemed a little odd/weird that the list was trying was creating a table and pointing to whatever it was currently pointing to just before the execution of the line completed and the list was updated to point at the newest created table.
Or am I way off here?
This is somewhat similar to what LIFO linked lists are in other languages(like c or c++). Yes, you were following it correctly.
Suppose my inputs are:(in the same order)
21
Hi
35
No
Then, my list is created as:
list = {
value = "No",
next = {
value = 35,
next = {
value = "Hi",
next = {
value = 21
next = nil
}
}
}
}
Essentially what is happening is, inside a for loop, you are creating a table and the next key is nil, initially. In subsequent loops, you are creating a table again and with the list variable you assign it to the next key, which is now a reference to the previous table, and so on.
I'll give you an example.
for i=1,3 do
list = {int=i, next=list}
end
When this executes, the first next key will be nil because list hasn't been defined yet. But in the next table its next key will be a reference to the previous table, and so on. If you try to print list.int and list.next, they would be referring to the table where int=3 because the for loop ends at 3 and thus the variable refers to that part. If you need to change this, you simply change the numeric for loop to something like
for i=3,1,-1 do
So it would actually look like this:
list = {int=1, next=nil}
list = {int=2, next=previousTable}
list = {int=3, next=previousTable}
or
list = {
int=3,
next = {
int=2,
next = {
int=1,
next=nil
}
}
}
Hope this helps.

Resources