ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Not possible to concatenate two strings in constant or INZ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Not possible to concatenate two strings in constant or INZ?

    So I'lve looked at the documentation for INZ and for constants. I couldn't find any restrictions on parameters. I found on this forum that you can't use a variable in INZ but nothing about concatenated strings.

    I want to create either a constant or an initialized variable containing text with a hex value for color. I want the string to be 'F8-' + x'22' + 'Do something'
    Neither
    Code:
    Dcl-C F8_String Const('F8-' + x'22' + 'Do something');
    nor
    Code:
    Dcl-S F8_String Char(25) Inz('F8-' + x'22' + 'Do something');
    work. I've gone about doing it differently but for future references, is that not possible to concatenate strings in constant declarations or INZ or is my syntax just wrong? Thanks.

  • #2
    Yeah, I don't think you can do that... maybe time to put in an RFE?

    You could do it like this, but its much harder to read:

    Code:
     
     Dcl-S F8_String Char(25) Inz('C6F86022C49640A2969485A388899587');

    Comment


    • #3
      OOps, that should be
      Code:
      inz(x'C6F86022 C49640A2 969485A3 88899587')

      Comment


      • #4
        Ok, I'll try it out. Thanks for the reply.

        Comment


        • #5
          If it can be a variable, you could put it in a data structure and initialize the parts separately.

          Dcl-Ds *n;
          *n Char(3) Inz('F8-');
          *n Char(1) Inz(x'22');
          *n Char(21) Inz('Do something');
          F8_String Char(25) Pos(1);
          End-Ds;

          In debug:
          > EVAL f8_string
          F8_STRING = 'F8-¦Do something '
          > EVAL f8_string:x
          00000 C6F86022 C49640A2 969485A3 88899587 - F8-.Do something
          00010 40404040 40404040 40...... ........ - .......
          Last edited by Barbara Morris; February 6, 2020, 04:43 PM. Reason: Edit: The CODE tag seems to be broken. I just put my code directly without tags ... hopefully it breaks the lines correctly. In preview, it breaks the lines, but doesn't include leading spaces ...

          Comment


          • #6
            Ok, that's a good way to do it. I'll keep this method in mind for future use.

            Comment

            Working...
            X