LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Use a variable for the integer in Fmt offset modifier

I'm trying to pluck values out of a long array of comma separated string
values.
I'm doing this within a loop and would like to use the loop interation to
point to the starting point in the array.

 

Here's what I have working so far:
Fmt (scratch,"%s<%s[i0t44]",transmitBuf);
Works great.

 

Now if I go in and change i0 to i3 then my modifier doesn't start looking
for a comma "," until after the 3rd character. Still working great. However....

If I try to use an integer called "loop" instead of the literal offset
value it blows up:

 

Fmt (scratch,"%s<%s[iloopt44]",transmitBuf);

Is there a way that I can use a variable for the integer portion of the
offset modifer?

 

Thanks All!

0 Kudos
Message 1 of 5
(2,974 Views)

You can look into this help page: search for "Using Asterisks (*) Instead of Constants in Format Specifiers" section, which I suppose is the direct solution to your question.

Nevertheless, I wander if this example can be more user friendly: String with Comma-Separated ASCII Numbers to Real Array



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 5
(2,970 Views)

Hi Roberto

Thank you. I actually need to use a symbolic value for the interger section of the modifer vs. the specifier.

So, in my example:

Fmt (scratch,"%s<%s[i0t44]",transmitBuf); 

 

I want to make the following substitution (Assume z=0)

 

Fmt (scratch,"%s<%s[izt44]",transmitBuf);

 

Some background...

I'm looking to loop index through a long CSV string array (transmitBuf) that looks like this:

1,PEEP,7,6,,,21,20,

 

So on my first loop when I use the following:

Fmt (scratch,"%s<%s[i0t44]",transmitBuf); 

 

scratch = "1"

... Perfect. I now do a string length of scratch (which equals 1)

and add 1 to it, I'm ready for my next loop which would

 

literally read like this:

Fmt (scratch,"%s<%s[i2t44]",transmitBuf); 

 

However, I want to put this inside a loop, so I would like to

increment a variable (++z) and use the following:

Fmt (scratch,"%s<%s[izt44]",transmitBuf); ---- Ka-Boom!

 

So it's the use of the variable in the modifer that blows up

the Fmt command.

 

appreciate any thoughts...

Thanks

Mark

 

 

 

 

0 Kudos
Message 3 of 5
(2,966 Views)

Seems you haven't read carefully my first link: what about

Fmt (scratch, "%s<%s[i*t44]", z, transmitBuf);



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 5
(2,953 Views)

Thanks Roberto,

Let me look into that.....

0 Kudos
Message 5 of 5
(2,941 Views)