Engineering Requirements Management

Engineering Requirements Management

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  String Array

    Posted Thu April 15, 2021 01:15 PM

    Hi, I would like to know if it is possible to create a dynamic string array which process each string input as an element of the array. Let me explain this question in more detail:

    I want to create a 2x2 dynamic string array named my_array. 1st row elements are "dog", "cat"; 2nd row elements are "sheep", "cow". When I recall my_array I want to get following results (lets assume first elements are indexed as 1)

    my_array(1,1): "dog"

    my_array(1,2): "cat"

    my_array(2,1): "sheep"

    my_array(2,2): "cow"

    And I also want this array to be updated dynamically for example I want to assign my_array(3,1): "eagle"

    Is there a way to use that kind of thing in DXL? Many thanks in advance?





    #DOORS
    #Support
    #Sustainability
    #EngineeringRequirementsManagement
    #SupportMigration


  • 2.  RE: String Array

    Posted Wed April 28, 2021 02:31 AM

    If applicable to your account, you may want to consider opening a case with IBM Support: https://www.ibm.com/mysupport/s/createrecord/NewCase





    #Sustainability
    #DOORS
    #Support
    #EngineeringRequirementsManagement
    #SupportMigration


  • 3.  RE: String Array

    Posted Thu May 06, 2021 08:38 AM

    My advice will be to not spend too many time in operator definition ... ;)

    But you can deal with any type of data with dxl objects ... here an example to build custom array with typical behaviour ...

    DxlObject create_array(int nline, int ncol){ DxlObject array = new() array ->"nline" = nline array ->"ncol" = ncol Skip data = create() int i for (i=0; i<nline*ncol; i++){ put(data, i, "") } array ->"data" = data return array } void set(DxlObject obj, string value, int posx, int posy){ int line_size = (int obj->"ncol") Skip values = (Skip obj->"data") if ( ! put(values, posx+posy*line_size, value) ){ delete(values, posx+posy*line_size) put(values, posx+posy*line_size, value) } } void delete(DxlObject obj, int posx, int posy){ set(obj, "", posx, posy) } string get(DxlObject obj, int posx, int posy){ int line_size = (int obj->"ncol") Skip values = (Skip obj->"data") string value if (find(values, posx+posy*line_size, value)) return value else return "" } void destroy_array(DxlObject obj){ Skip values = (Skip obj->"data") delete values delete obj } void print_array(DxlObject obj){ Skip values = (Skip obj->"data") int ncol = (int obj->"ncol") int nlin = (int obj->"nline") int i, j for i in 0:nlin-1 do { for j in 0:ncol-1 do print get(obj, j, i) "\t" print("\n") } } // ---------- // How to use it ! // ---------- DxlObject my_array = create_array(4,4) int x, y for x in 0:3 do for y in 0:3 do set(my_array, "(" x "," y ")", x, y) print_array( my_array ) print "//-----------------\n" delete(my_array, 1, 1) print_array( my_array ) print "//-----------------\n" set(my_array, "done!", 1, 1) print_array( my_array ) destroy_array my_array

    Enjoy ;)





    #Sustainability
    #SupportMigration
    #DOORS
    #Support
    #EngineeringRequirementsManagement