04-05-2016 05:12 AM
Hi,
I'm searching to modifie the format of a integer variable
For example :
int nb ;
nb=1;
change the content of the variable nb from 1 to 000001
Solved! Go to Solution.
04-05-2016 05:41 AM
Can you calrify what do you mean?
Are you asking for scanning a value from a string?
Are you asking to format your data someway?
What do the prepending zeros stand for?
04-05-2016 06:06 AM
All i need is to fill a number with leading zeros
for(i=0;i <999999; i++)
{
vl_compteur=i;
//if i==0 , we need to change the content of to 000000
Fmt(Sn,"%s<%s%s%s%s",DD,MM,YYYY,vl_compteur);
//the variable DD means DayDay, MM MonthMonth,YYYY YearYearYearYear
}
int this case Sn contient 050420160, i want that the variable Sn 05042016000000
04-05-2016 06:20 AM - edited 04-05-2016 06:23 AM
Ok, so the problem is formatting integers into a specified formats.
As you can see looking to the help for Fmt function, you are using a wrong specifier: at least the loop index it's an integer so you should use %d instead of %s. Here you are implicitly stating DD, MM, YYYY are strings, so the correct format string is the following:
Fmt (Sn, "%s<%s%s%s%d[w6p0]", DD , MM, YYYY, vl_compteur);
I leave to you to interpret the symbols I used based on the help page I linked.