FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FileStr()
Posts: 464
Joined: Tue May 16, 2006 07:47 AM

FileStr()

Posted: Wed Apr 01, 2009 11:02 AM

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

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: StrFile()

Posted: Wed Apr 01, 2009 11:39 AM

Hi Doug,

Nice to see you again here :-)

What parameters are you using to call StrFile() ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: StrFile()

Posted: Wed Apr 01, 2009 11:40 AM

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
Posts: 464
Joined: Tue May 16, 2006 07:47 AM

Re: FileStr()

Posted: Wed Apr 01, 2009 11:55 AM

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

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: FileStr()

Posted: Wed Apr 01, 2009 12:23 PM
This sample works fine here:

Code (fw): Select all Collapse
FUNCTION MAIN()

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

    ? LEN( cBuf )

    INKEY( 0 )

    RETURN NIL


EMG
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: FileStr()

Posted: Wed Apr 01, 2009 12:44 PM

I guess that code is equivalent to:

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

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion