Multi dimension arrays in OAL

homepage Forums BridgePoint/xtUML Usage and Training Multi dimension arrays in OAL

  • This topic has 2 replies, 2 voices, and was last updated 7 years ago by TI.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1288
    TI
    Participant

    Is it possible to use multi dimension arrays in OAL?

    Such like , my_array[3][3].

    If we can use multi dimension arrays, it would be very convenient to implement some datapath algorithms.

    //TI.

    #1292
    keithbrown
    Keymaster

    Multi-dimensional arrays are supported both as transients and modeled attributes. As with single-dimensional transients as arrays in OAL, you must set the maximum extent first:

    // Right:
    my_array[1][1] = 3;
    my_array[0][0] = 0; // Order of this and next two lines does not matter
    my_array[0][1] = 1;
    my_array[1][0] = 2;

    // Wrong:
    my_array[0][0] = 0;
    my_array[0][1] = 1; // Parser will indicate Array Index Out of Bounds
    my_array[1][0] = 2;
    my_array[1][1] = 3;

    #1293
    TI
    Participant

    Hi Keith,

    Thank you for replying.
    I confrimed that I could.

    OAL is —
    my_array[1][1] = 3;
    my_array[0][0] = 0; // Order of this and next two lines does not matter
    my_array[0][1] = 1;
    my_array[1][0] = 2;

    LOG::LogInfo(message: “Arrays are descripted below”);
    LOG::LogInteger(message:my_array[0][0]);
    LOG::LogInteger(message:my_array[0][1]);
    LOG::LogInteger(message:my_array[1][0]);
    LOG::LogInteger(message:my_array[1][1]);

    Out put is —
    User invoked function: func1
    LogInfo: Arrays are descripted below
    LogInteger: 0
    LogInteger: 1
    LogInteger: 2
    LogInteger: 3

    //TI

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.