FileStr()

Post Reply
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

FileStr()

Post by xProgrammer »

Hi all

I have just had to write some code to run on a Windows box. I wrote the code on a linux machine where it ran fine and then compiled under Windows. It compiled and ran but errored out. The problem turned out to be theFileStr() function which on Linux seemed to cope with fair sized files (certainly up to 160K) whereas under Windows (XP) it seemed to have a limit (from memory about 30K).

I programmed around this using FOpen(), FRead() and a pre-allocated buffer, but I was wondering if anyone else had struck this problem?

Regards

Doug
Last edited by xProgrammer on Wed Apr 01, 2009 11:52 am, edited 1 time in total.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: StrFile()

Post by Antonio Linares »

Hi Doug,

Nice to see you again here :-)

What parameters are you using to call StrFile() ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: StrFile()

Post by Antonio Linares »

You can also use MemoWrit() to save a string to a file.

Its easier than using FCreate(), etc.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: FileStr()

Post by xProgrammer »

OOps! I meant FileStr() NOT StrFile()!

I was just calling as follows:

FileData := FileStr( FileName )

That is I omitted parameter 2 (nBytes) so it should read the entire file (and does so under Linux) but under Windows seems to only read the first 30K or so.

Sorry about mixing up FileStr() and StrFile().

Regards

Doug
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FileStr()

Post by Enrico Maria Giordano »

This sample works fine here:

Code: Select all

FUNCTION MAIN()

    LOCAL cBuf := FILESTR( "TEST.EXE" )

    ? LEN( cBuf )

    INKEY( 0 )

    RETURN NIL
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FileStr()

Post by Antonio Linares »

I guess that code is equivalent to:

local cText := MemoRead( "test.exe" ) :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply