>>>I'm using VFP 5.0 and there is no FILETOSTR command. Is there an equivalent in VFP 5.0?
>>
>>Here is something that's a UDF that's basicly the same thing
>>
>>
>>*---------------------------------------------------------------------*
>>* file2str - takes a file and returns it contents back *
>>*---------------------------------------------------------------------*
>>FUNCTION FILE2STR
>>PARAMETER pc_file
>>PRIVATE ln_hndl, ln_size, lc_string
>>STORE 0 TO ln_hndl, ln_size
>>lc_string = SPACE(0)
>>
>>IF TYPE('pc_file') = "C" .AND. FILE(pc_file)
>> ln_hndl = FOPEN(pc_file)
>> *-- Move to the bottom of the file
>> ln_size = FSEEK(ln_hndl, 0, 2)
>> *-- Move to the top
>> =FSEEK(ln_hndl, 0, 0)
>> lc_string = FREAD(ln_hndl, ln_size)
>> =FCLOSE(ln_hndl)
>>ENDIF
>>
>>RETURN (lc_string)
>>
>
>Just an FYI..
>
>This will crash if ln_size > 16,777,184 (VFP6.0 sp5). Building lc_string inside a DO WHILE !FEOF(ln_hndl)loop will create large strings (> 16,777,184) as will FILETOSTR(). Such strings can be manipulated without erroring, but I would not trust the results in an app since the maximum # of characters per character string or mem var is stated to be 16,777,184.
>
>Bruce
Yep I knew there was a size limit to the string, but this is a function written back in FPW 2.6. It had a size check on the file using FSIZE() but I didn't include that because I didn't know what the string size limit is in VFP 5. I also think that if you are using a file that is bigger than 1 Meg you probably shouldn't convert it to a string if FoxPro lets you or not, but that's just my personal opinion.
Charles
"The code knows no master." - Chuck Mautz
"Everybody is ignorant, only on different subjects." - Will Rogers