dodicat wrote:you could return
return chr(t1.s[0],t1.s[1],t1.s[2],t1.s[3],t1.s[4],t1.s[5],t1.s[6],t1.s[7])
Which is just t1.s laid out no frills.
but it looks ugly I suppose.
Using CHR() plus eight references is probably not optimal. I did a speed test with LEFT() and my UnFix function. Over 800.000 iterations LEFT() takes 0.10 seconds while Unfix() takes 0.17 seconds. A
#define unfix left looks like the cleanest/fastest and most meaningful solution.
Still, I'm not sure why FB would cut a fixed length string at the first chr(0) occurrence when converted directly to variable length. After all the LEN() function knows how to get its full size even if the string is padded with all null characters:
Code: Select all
dim buffer as string * 15
print len(buffer)
buffer = chr(0)
print len(buffer)
Which makes me wonder, how can we obtain the length of a fixed string. It doesn't have a descriptor like a variable length string.