I can't remember how to convert a char array to a string.
Larry
convert?
A sting is a character array. Where is the CHAR array coming from.
My guess:
def ca[250]:char /* must be < 255 */
def cs:string
def i:int
... code loading ca array
cs = ""
for i=0 to 250
cs += ca[i]
next i
print cs
end
Probably too simplistic, but should work.
Bill
Bill,
If he just wanted to copy the contents of the char array to a string, or memory for that matter, then using a pointer is easiest.
char myarray[1000]
pointer pArray
pArray = myarray
#<string>pArray = somestring
...
somestring = #<string>pArray
I asked him where the CHAR array was coming from, as it is sometimes easier to use an ISTRING, especially when sending UDT references to an API function, since you can access it as a string directly.
Paul.
It's coming from the 32 char font name in a LOGFONT return by enumfontfamiliesex.
Before I posted I used the for loop (sort of like Bill suggested) but I tested to see when I hit Chr$(0) because the character array contents could be less than the 32. Don't know if the test was really required.
I had also tried what Paul said:
where I messed up was usingpArray = myarray[0]instead ofpArray = myarray
but thought there was an easier way.
What I did was create my own logfont UDT and changed the name declaration from
name as char[32] to name as istring[32] and it worked fine.
but I believe Paul's way, as always, is the way to go.
Larry
In that case I would use the ISTRING. In fact I have used it ;)