04-02-2012 04:24 PM
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!
04-02-2012 05:03 PM
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
04-02-2012 05:27 PM
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
04-03-2012 12:01 AM
Seems you haven't read carefully my first link: what about
Fmt (scratch, "%s<%s[i*t44]", z, transmitBuf);
04-03-2012 08:35 AM
Thanks Roberto,
Let me look into that.....