Topic
11 replies Latest Post - ‏2013-11-19T23:47:44Z by TD66_d_f
TD66_d_f
TD66_d_f
9 Posts
ACCEPTED ANSWER

Pinned topic Integer to string with level

‏2013-11-14T16:58:57Z |

I'm just starting with DXL and DOORS and need some help. 

I want to add a column to a view that uses DXL to print 'this row is at level: " <level goes here>

As I understand it level(Object o) returns an integer.

 

I've added layout DXL that does not generate errors.

Object o = current
int L = level(Object o)

display "hi there"

If I try:

display "hi there" stringOf(L)

I get 'incorrect arguments for function (stringOf)'

??? This can't be that hard. What am I missing?

Thanks for any tips.

  • adevicq
    adevicq
    154 Posts
    ACCEPTED ANSWER

    Re: Integer to string with level

    ‏2013-11-14T17:07:43Z  in response to TD66_d_f

    Hi,

    Try:

    display "hi there" L ""

     

    regards

    alain

    • TD66_d_f
      TD66_d_f
      9 Posts
      ACCEPTED ANSWER

      Re: Integer to string with level - appended + question

      ‏2013-11-14T17:16:14Z  in response to adevicq

      That worked.  Thanks.

      The output wasn't as expected.  L = 1 for all Oject Levels so 'Level()' must not be what I want.

      Back into the documentation.

      Thank you for the quick reply!  It's very much appreciated.

      Doug

      <edit>

      If I change from

      Object o = Current

      to o = obj

      I get the correct level.

      Why does the original setting of 'o' not return the right object?

      Updated on 2013-11-14T17:31:05Z at 2013-11-14T17:31:05Z by TD66_d_f
  • sekrbo
    sekrbo
    39 Posts
    ACCEPTED ANSWER

    Re: Integer to string with level

    ‏2013-11-15T09:52:33Z  in response to TD66_d_f

    current Object is the selected object, not the object / row that your on for layout DXL.

     

    the easiest way to code this would probably be:

    display ("hi there " level(obj) "")

    • TD66_d_f
      TD66_d_f
      9 Posts
      ACCEPTED ANSWER

      Re: Integer to string with level

      ‏2013-11-15T11:35:54Z  in response to sekrbo

      So in this case 'Current' would have been the dxl column rather than the row and the column would always be at level 1?

      I agree on the code.  When I'm learning a new language, I tend to be overly verbose so if I need to debug problems I have intermediate variables I can confirm.  Heck, I tend to be overly verbose just because I find it easier to debug my own code later...

      Thanks for the reply.

      • sekrbo
        sekrbo
        39 Posts
        ACCEPTED ANSWER

        Re: Integer to string with level

        ‏2013-11-15T11:52:00Z  in response to TD66_d_f

        No. The current object is the object in the module that is selected, with the thicker upper and lower border. So unless you actually click or have the script change the current object, it would be the same object referenced each time. Like a selected row in a spreadsheet. So if you have a layout column displaying the level of the current object, this will change each time you click on a new object at a different level. The variable 'obj' however will always refer to the object of the 'row' in which it is used.

        Don't know if that makes sense...

      • GregM_dxler
        GregM_dxler
        160 Posts
        ACCEPTED ANSWER

        Re: Integer to string with level

        ‏2013-11-15T13:35:34Z  in response to TD66_d_f

        Hello,

        For layout dxl, it is a little different than regular dxl.  The layout dxl will run on every object in the display set.  In a sense you can think of it as being duplicated into every object.  This is also another reason why you don't need to loop thorugh all objects using a layout dxl to populate all objects.

        Layout dxl uses the variable obj that is autodeclared and automatically set to the object that the layout dxl is in.  Any other object that is declared, is not automatically set.  You have to assign it to something.  When you assign it to "current", it is assigned to the object that is selected, not the one the layout dxl is in.  Since the layout dxl that is run in each object has object o assigned to the same selected object, that is why you kept getting the same level.

        Another thing with the layout dxl, you display (or displayRich) the output you want.  This puts the output to be shown in the dxl column.  Since the layout dxl is a different copy for each object, you don't have to state which object to display the output in, it will display in the object that the copy of the layout dxl is in.  Essentially the obj object.

        Hope this helps,

        Greg

      • TD66_d_f
        TD66_d_f
        9 Posts
        ACCEPTED ANSWER

        Re: Integer to string with level

        ‏2013-11-15T16:04:40Z  in response to TD66_d_f

        Secrobo and Greg,

        This is getting to be kind of Zen like: the object is the selected object unless its another object in which case it's the other object...ommmmmmmmm

        Right now, I kind of have the gestalt for what this means but haven't internalized it yet.  One problem I'm having is the that I lack a real time debugger that lets me step through the code and watch when/where variables are created, their values, and the properties of any objects used by the code.  I know Sodius sells such a product but that's not in the cards for me :-((  I'm vaguely aware that I can dump stuff to output files but I really find that being able to stop and examine attributes, properties, etc in real time is a huge help.  It's just going to take me some time to 'get' the object model.

        I think the good news is that my real job is doing IBM/Lotus Notes development and it is also a NoSQL type system so the whole concept of 'everything is an object' isn't foreign; it's just that the environment is so very different I need to build a mental model of what's going on so it makes more sense and adapt to the terminology.  Time, practice, and running face first into the wall will get me through (along with the help of kind folks like you).

        Thank you both so very much.

        Doug

        • llandale
          llandale
          2939 Posts
          ACCEPTED ANSWER

          Re: Integer to string with level

          ‏2013-11-19T18:19:32Z  in response to TD66_d_f

          [1] Yes, you can turn normal variables into strings by "concatenating" them with a string that follows.  The "space" means "concatenate".  It is common to concatenate the null string to do the conversation.  The layout "display" command requires a string.  So, using parenthesis to highlight the actual functions and parameters, you get:

          • display("Level is " L "").  Or, to be rediculously precise:
          • display(("Level is " (L ""))).  Order of precedence is:
            1. L "", convert integer L to a string
            2. Concatenate "Level is " with the result of 1.
            3. display the result of 2.

          "Normal variables" have values and don't include "Handles" such as "Object" or "Module".

          Having said that, there are a few "stringOf()" functions such as for "UserType".

          [2] Just browsed this thread but I think I get the jist.  Your error is failure to distinquish the "current" object as the one selected verses the natural context of Layout/Attr-DXL which is "this" object, auto-populated in auto-declared variable "obj".  Certainly you want Layouts to display info about the object in the row, not some other object currently selected.

          The following should prove useful to help see the difference; then delete the 1st two lines.

          • Object o = current
          • display "current = " identifier(o) " has level " level(o) ""
          • display "obj        = " identifier(obj) " has level " level(obj) ""

          -Louie

          OK, actually you should technically check "if (null o)" before using "o".  Likewise "identifier(obj)" will fail in normal DXL since variable "obj" will have null value.

          • TD66_d_f
            TD66_d_f
            9 Posts
            ACCEPTED ANSWER

            Re: Integer to string with level

            ‏2013-11-19T23:42:35Z  in response to llandale

            I am so bookmarking this thread!

            Thanks.

  • llandale
    llandale
    2939 Posts
    ACCEPTED ANSWER

    Re: Integer to string with level

    ‏2013-11-19T18:22:31Z  in response to TD66_d_f

    I'm just starting with DXL and DOORS and need some help. 

    Use the DXL edit window to "browse" for DXL.  Browse around for native deployed DXL code, get a copy, run it, and try to figure out how the results were generated by following the code.  Good way to get used to DXL.

    -Louie

     

    • TD66_d_f
      TD66_d_f
      9 Posts
      ACCEPTED ANSWER

      Re: Integer to string with level

      ‏2013-11-19T23:47:44Z  in response to llandale

      Great suggestion.  I've been browsing code but not actually running it.  I tend to learn best by working on a specific (and useful) task, break it down to small steps, build each step until it works, then add the next thing.  When I run a big old slug of code someone else wrote, I tend to spend a ton of time getting inside the author's head; it works but is just slow.

      Thanks again.