homepage › Forums › BridgePoint/xtUML Usage and Training › Using single-dimension, dynamically-sized arrays in instance-based operations
- This topic has 5 replies, 4 voices, and was last updated 10 months, 1 week ago by
ablair.
-
AuthorPosts
-
November 17, 2022 at 4:06 pm #7611
ablair
ParticipantHi, I’m struggling with BP. I want to create an instance-based operation with no parameters that returns a single-dimension array of integers … but I don’t know in advance the size of the array.
Via the Properties view, I’ve declared that the Return Array Dimension for the operation is []
I’m using OAL to define the operation. Can someone please illustrate how I might capture integral values as array elements in the body of the operation, and then return the array of values? I’m lost!
TIA.
[Once I understand how to return 1D arrays of values from an operation, I’m assuming that I can use this mechanism within the Model Verifier(?)]November 17, 2022 at 4:34 pm #7612Bob Mulvey
KeymasterHi Alasdar,
I hope I am not leading you down a rabbit hole. It has been a long time since I have look at this. However, when looking for examples I think about the BridgePoint unit tests and manual test cases. I see this issue which describes array annual tests:
https://support.onefact.net/issues/1995Notes in that issue read there is a test model.issue, but it may be worth looking at.
I do recall development notes written about this too, but searching quickly I am not seeing them.
Bob
November 17, 2022 at 4:36 pm #7613cort
Keymaster…at the moment, I do not have time to look at an example model, but I can make a couple of comments.
1) There are setting in the BridgePoint preferences to enable/disable fixed and dynamic arrays.
2) Array support came in BridgePoint relatively late in the game, and support is mixed, but I am pretty sure that Verifier supports anything that the editor supports.
3) You may have better luck passing a reference parameter rather than trying to return an array. This is what I wanted to check on.November 17, 2022 at 7:06 pm #7614ablair
ParticipantThanks Bob, Cort. I’ll look into your suggestions.
November 18, 2022 at 1:00 am #7615John Wolfe
ParticipantVerifier supports arrays, including variable-length ones. But, at the moment, I cannot remember the magic for declaring a variable-length array as a temporary variable. I think I’ve done it in the past, so let me know if it matters to you, and I’ll try to recall how to do it.
In any case, here is an example of an instance-based operation returning a variable-length array of integers. It uses an attribute declared as a variable-length array to collect the values and then returns the value of that attribute.
https://github.com/johnrwolfe/ArrayReturnNovember 18, 2022 at 5:50 am #7616ablair
ParticipantMany thanks, John. The syntax needed is clear from your example … and I think I can live without the variable-length array as a temp variable.
Thanks all! -
AuthorPosts
- You must be logged in to reply to this topic.