Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I need some string manipulation help
Message
From
30/06/2008 16:25:58
 
 
To
30/06/2008 16:05:13
Mike Sue-Ping
Cambridge, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01327713
Message ID:
01327722
Views:
8
>I'm trying to prepare a string to pass to the RMChart control. The string I'm attempting to build starts off as:
>
>m.lcData = "0*0*0*0*0*0*0*0*0*0*0*0*"
>
>
>I have a table that stores a count of 'thingys' for a given month. There are two integer columns - the first value represents a month (1-12) while the second is the count of 'thingys'. The data in the table could look like this:
>
>mth   cnt
>4      129   (April has 129 occurences)
>8        44   (August has 44 occurences)
>12        1   (December has 1 occurence)
>
>
>What I'd like to do is call some VFP string functions to have the string variable "adjusted" to look like this:
>
>m.lcData = "0*0*0*129*0*0*0*44*0*0*0*1*"
>
>
>I've tried STRTRAN() in a scan loop but it fails to do what I need with the 4th parameter:
>
>STRTRAN(m.lcData, '0*', transform(cnt)+'*', mth, 1)
>
>
>Anyone have a better idea?

Another approach would be to build the string from scratch, rather than replacing:
SELECT ;
  * ;
  FROM SomeTable ;
  INTO CURSOR Temp ;
  ORDER BY Mth

INDEX ON Mth TAG Mth

m.lcData = ""

FOR m.lnIx = 1 TO 12 STEP 1
  m.lcData = m.lcData + IIF( SEEK( lnIx, "Temp" ), LTRIM( STR( Temp.Cnt) ) , "0" ) + "*"

ENDFOR

USE IN Temp
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform