LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan Modifier Integer To long Integer

Solved!
Go to solution

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

 

 

0 Kudos
Message 1 of 4
(3,790 Views)

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?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(3,781 Views)

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

 

 

 

0 Kudos
Message 3 of 4
(3,775 Views)
Solution
Accepted by topic author FENM

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(3,769 Views)