Page 1 of 1

Message Setting

Posted: May 29th, 2021, 11:37 am
by pradhanra01
Hi Gregory Martin,

I have a problem regarding Message setting on CSPro 7.5, I want to allign multiple line message in central. When we normally write :
ERRMSG("Education Survey\nJune 2021 \n{Valid till 2021/07/10}");

errmsg shows in left align in multiple line, I am trying to set central allign. Is it Possible to do ?

Regards,
Ramesh Pradhan

Re: Message Setting

Posted: June 1st, 2021, 8:45 am
by Gregory Martin
There is no direct way to say that you want center alignment as opposed to left alignment. However, if you really want this behavior, you could write a function to pad the message lines so that they appear centered:
function MultilineMessage(list string message_lines)

   
numeric max_line_length;

   
do numeric ctr = 1 while ctr <= message_lines.length()
        max_line_length =
high(max_line_length, length(message_lines(ctr)));
   
enddo;

   
string full_message_line;

   
do numeric ctr = 1 while ctr <= message_lines.length()

       
if ctr > 1 then
           
full_message_line = full_message_line + "\n";
       
endif;

       
numeric left_spaces_needed = ( max_line_length  - length(message_lines(ctr)) ) / 2;

       
do numeric space_ctr = 1 while space_ctr <= left_spaces_needed
            full_message_line = full_message_line +
" ";
       
enddo;

        full_message_line = full_message_line + message_lines(ctr);

   
enddo;

   
errmsg("%s", full_message_line);

end;
You would then call the function like this:
    list string message = "Education Survey",
                         
"June 2021",
                         
"{Valid till 2021/07/10}";

    MultilineMessage(message);

Re: Message Setting

Posted: June 2nd, 2021, 8:07 am
by pradhanra01
Thank You Gregory Martin

I will apply it in my App

Thank You So much

Regards,
Ramesh Pradhan