Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strings 2

Status
Not open for further replies.

rclarke

Technical User
May 14, 2001
78
GB
Could anyone please tell me how to specifically place data in a string ie &quot;<=&quot; in possitions 1 & 2 of the string or array do I use the Left and substr commands or something like that

Please help am banging head on big brick wall

thanks in advance

Rachel

 
Rachel

One way using SUBSTR()

lcString = [The cat sat on the mat]
lcText2Insert = [next to me]
lnPoint = 12
lcString = SUBS(lcString,1,lnPoint) + lcText2Insert + SUBS(lcString,lnPoint,LEN(lcString) - lnPoint + 1)

? lcString

Chris :)
 
Thankyou CHris

May be you could help me further or somebody

Can you store Binary Characters in to a string

I.E if I convert integer values into binary Characters using BINTOC and CTOBIN can I store those in a string as you have done above.

All I keep getting is that I passed an invalid variable

Is there another way of doing the whole thing

As you can tell don't use VFP very much infact first project with the thing

Thanks In Advance

Rachel
 
Rachel

Why convert integer to binary and back?

Why not convert integer to string and back?

lnValue = 99
lcValue = ALLT(STR(lnValue))

? lnValue

The STR() function will allow you to control decimal places if required, and you could use code similar to the second post.
Chris :)

 
I didn't know it could be done

But I do now and I will use it

Thank yo Very Much

You have saved my Head from even more sevre bruising

 
Hi Rachel,

Regarding your first question, an alternate method is to use the STUFF command:

string = STUFF(string, 1, 0, '<=')

Jim
 
Thanks Jim

A question to you now

Does where you put 1,0 define the first to space in the string

I.E if I put 4,3 would that stuff them in spaces 3 and four?

I know probably a thick question but am only learning

Also I am using Chris's STR() sugestion (works Well with integer Numbers) and have defiened that there are 4number before the decimal point and 4 numbers after.

The field is Numeric and the input mask is 9999.9999

why does it return (if I put in 1211.1211) 12000 SHould it do this?

Nobody around me has touched fox pro so I am sorry to be a pain but you guys are the best help I have found on foxpro.
 
Hi Rachel,

I think you can get your answers from the HELP writeups for STUFF() and STR().

Jim
 
With the STR() function you can specify the length of the string and how many decimals places.

STR(nExpression[,nLength[,nDecimalPlaces]])

This might help you.

Another method to solve your original question -- You can also use concatenation. e.g.

cString = &quot;9999.9999&quot;
cString = &quot;<=&quot; + cString

Chuck Davis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top