Concatenate text fields

This question is answered

I have multiple text fields in a table I wish to display as one field on a form.

Can you please help me with my code

Display FGT_CoverFabricArray1 fgt_psm_CombinedFabricType()

{

FGT_CoverFabricArray1 fabrics;

fabrics = this.PillowCoverFabricType +

this.PillowCoverFabricType2 +

this.CoverFabricType[1] +

this.CoverFabricType[2] +

this.CoverFabricType[3] +

 this.CoverFabricType[4] +

 this.CoverFabricType[5] +

 this.CoverFabricId1[1] +

 this.CoverFabricId1[2] +

 this.CoverFabricId1[3] +

 this.CoverFabricId1[4] +

 this.CoverFabricId1[5];

 return fabrics

}

Verified Answer
  • there could be few choices, you can use like that

    str output;

    output = strfmt("%1 %2 %3 %4 %5", field1, field2, field3, field4, field5);

    // similar u can add more fields.

    other option could be

    you can use the SysDictTable class

    get the field ids for all the field in your table

    loop through those ids and inside loop you can write some what similar

    output = output + this.(fieldid);

    you might also need to check the datatype before concatinate.

    easy way to use strfmt method

    output = output + strfmt("%1", this.(fieldId));

  • return output;
    }

    ";"

    :)

  • yep variable decleartion seperator is missing

    ie ;
     code would be like

    Display str fgt_psm_CombinedFabricType()
    {

        str output;
    ;
        output = strfmt("%1 %2 %3 %4 %5", this.PillowCoverFabricType, this.PillowCoverFabricType2, this.CoverFabricType[1], this.CoverFabricType[2], this.CoverFabricType[3]);
     
      return output
    }

     

     

     

All Replies
  • there could be few choices, you can use like that

    str output;

    output = strfmt("%1 %2 %3 %4 %5", field1, field2, field3, field4, field5);

    // similar u can add more fields.

    other option could be

    you can use the SysDictTable class

    get the field ids for all the field in your table

    loop through those ids and inside loop you can write some what similar

    output = output + this.(fieldid);

    you might also need to check the datatype before concatinate.

    easy way to use strfmt method

    output = output + strfmt("%1", this.(fieldId));

  • Thanks Amir

    This is my code below but I get a SYntax error on the }
    Can you tell me what is wrong with my code ???
    Thanks

    Display str fgt_psm_CombinedFabricType()
    {

        str output;

        output = strfmt("%1 %2 %3 %4 %5", this.PillowCoverFabricType, this.PillowCoverFabricType2, this.CoverFabricType[1], this.CoverFabricType[2], this.CoverFabricType[3]);
     
      return output
    }

  • return output;
    }

    ";"

    :)

  • yep variable decleartion seperator is missing

    ie ;
     code would be like

    Display str fgt_psm_CombinedFabricType()
    {

        str output;
    ;
        output = strfmt("%1 %2 %3 %4 %5", this.PillowCoverFabricType, this.PillowCoverFabricType2, this.CoverFabricType[1], this.CoverFabricType[2], this.CoverFabricType[3]);
     
      return output
    }

     

     

     

  • Thanks chaps, just didn't spot that one !

    ;)