FileStr()

FileStr()

Postby xProgrammer » 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
Last edited by xProgrammer on Wed Apr 01, 2009 11:52 am, edited 1 time in total.
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: StrFile()

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41901
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: StrFile()

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41901
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FileStr()

Postby xProgrammer » 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
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: FileStr()

Postby Enrico Maria Giordano » Wed Apr 01, 2009 12:23 pm

This sample works fine here:

Code: Select all  Expand view
FUNCTION MAIN()

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

    ? LEN( cBuf )

    INKEY( 0 )

    RETURN NIL


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

Re: FileStr()

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41901
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 33 guests