Message Setting

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
pradhanra01
Posts: 38
Joined: August 27th, 2017, 2:43 am

Message Setting

Post 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
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Message Setting

Post 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);
pradhanra01
Posts: 38
Joined: August 27th, 2017, 2:43 am

Re: Message Setting

Post by pradhanra01 »

Thank You Gregory Martin

I will apply it in my App

Thank You So much

Regards,
Ramesh Pradhan
Post Reply