Discussions about CSEntry
lmangcahan
Posts: 25 Joined: September 7th, 2021, 3:45 am
Post
by lmangcahan » November 23rd, 2021, 7:43 am
Hi CSPro Team,
Hope all is well. Can you help me simplify my code below? I declared F2001...F2004 individually since when I try displaying their values using concat("F2",edit("999",x)) it display the value F2001 and not the value stored to this variable.
Thank you in advance.
Numeric F2001,F2002,F2003,F2004;
filewrite(summary_file," TOTAL ERRORS PER ERRORCODE: ");
filewrite(summary_file," F2001: %d", F2001);
filewrite(summary_file," F2002: %d", F2002);
filewrite(summary_file," F2003: %d", F2003);
filewrite(summary_file," F2004: %d", F2004)
aaronw
Posts: 565 Joined: June 9th, 2016, 9:38 am
Location: Washington, DC
Post
by aaronw » November 23rd, 2021, 11:00 am
The assignments to F2001, F2002, F2003, and F2004 are what are of interest here. Have you just tried displaying them with an error message?
errmsg ( "%d, %d, %d, %d" , F2001, F2002, F2003, F2004);
If these values are incorrect you need to take a step back and look why that is.
lmangcahan
Posts: 25 Joined: September 7th, 2021, 3:45 am
Post
by lmangcahan » November 23rd, 2021, 11:13 pm
Hi Aaronw,
The code below actually works but I was thinking if I can simplify it in CSPRO. I have over hundred errorcodes to declare and maybe there's a shorter steps to take. Thank you.
Gregory Martin
Posts: 1795 Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC
Post
by Gregory Martin » November 24th, 2021, 9:23 am
You can potentially use the getvalue function. Something like this:
do numeric ctr = 2001 while ctr <= 2004
string item_name = maketext ("F%d" , ctr);
summary_file.write("%s: %d" , item_name, getvalue (item_name));
enddo ;