Err Msg Select function

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Ali
Posts: 19
Joined: June 6th, 2019, 4:43 am

Err Msg Select function

Post by Ali »

I'm new to cspro and tried to display an error message together with select function. I got an error message says
"Expecting right parenthesis ')' in a function call near line 11 in P35 procedure.
Here is the logic I used:

PROC P35
if P04 + P07 + P10 + P13 + P32 <> P01 then
errmsg("The sum of cattle for < 6 months(%d), 6 months-1 year (%d), 1-3 years(%d), 3-10 years (%d) and 10 years and older (%d) differs from Total Cattle of all age (%d)",
P04, P07, P10, P13, P32, P01)
select("Fix number of < 6 months cattle", P04,
"Fix number of cattle for 6 months-1 year", P07,
"Fix number of cattle for 1-3 years", P10,
"Fix number of cattle for 3-10 years", P13,
"Fix number of cattle for 10 years and older", P32,
"Fix number of Total cattle of all age", P01);
endif;

But if I remove one row at the middle in the select function it works. Can you help me on this?
Thanks;
Ali
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Err Msg Select function

Post by josh »

There is a limit of five buttons that can be added to the select clause of the error message and in your logic there are six. Unfortunately the error message is not at all helpful. However if you remove one of the buttons it should work fine. If you really want all six buttons you could use the accept function instead. It is a bit more verbose but would do the same thing:
    if P04 + P07 + P10 + P13 + P32 <> P01 then
        string
message = maketext("The sum of cattle for < 6 months(%d), 6 months-1 year (%d), 1-3 years(%d), 3-10 years (%d) and 10 years and older (%d) differs from Total Cattle of all age (%d)", P04, P07, P10, P13, P32, P01);
       
numeric choice = accept(message,
                               
"Fix number of cattle for 6 months-1 year",
                               
"Fix number of cattle for 1-3 years",
                               
"Fix number of cattle for 3-10 years",
                               
"Fix number of cattle for 10 years and older",
                               
"Fix number of Total cattle of all age");
       
if choice = 1 then
            reenter
P04;
       
elseif choice = 2 then
            reenter
P07;
       
elseif choice = 3 then
            reenter
P10;
       
elseif choice = 4 then
            reenter
P13;
       
elseif choice = 5 then
            reenter
P32;
       
elseif choice = 6 then
            reenter
P01;
       
else
            reenter
;
       
endif;
   
endif;
Ali
Posts: 19
Joined: June 6th, 2019, 4:43 am

Re: Err Msg Select function

Post by Ali »

Thanks Josh; solved!
Ali
Post Reply