Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I need some string manipulation help
Message
 
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:
01327721
Views:
11
This message has been marked as the solution to the initial question of the thread.
Hi Mike,

What about using Stuff()?
m.lcData = "0*0*0*0*0*0*0*0*0*0*0*0*"

create cursor c_test (month I, cnt I)

insert into c_test values (4, 129) &&   (April has 129 occurences)
insert into c_test values (8, 44) &&   (August has 44 occurences)
insert into c_test values (12, 1) &&   (December has 1 occurence)


scan
	m.lcData		= Stuff(m.lcData, At('*', m.lcData, c_test.month) - 1, 1, Transform(c_test.cnt))
endscan
? m.lcData
Or you can build the string from scratch, not sure which is better.

[Update]
Building from scratch would be like this
lcData			= ''
go top in c_test
for lnMonth = 1 to 12
	if lnMonth = c_test.month
		lcData			= lcData + Transform(c_test.cnt) + '*'
		skip in c_test
	else
		lcData			= lcData + '0*'
	endif
next lnMonth

? m.lcData
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform