Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
StrToFile Equivalent in FPD26?
Message
From
15/02/2003 09:27:06
 
 
To
10/02/2003 10:52:33
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00751416
Message ID:
00753688
Views:
18
This message has been marked as the solution to the initial question of the thread.
>Is there a strtofile equivalent in FPD26? I'd like to run the code below in FPD26 (see compile directives-only bottom portion is for FPD26) but it bombs out at the StrToFile portion of course:
>
Tracy;

Here is both filetostring/stringtofile compatibles functions for 2.6:
FUNCTION filetostring
LPARAMETER lcdatafile                     && .txt (line sequential) file
lndfh=FOPEN(lcdatafile)
lcparameter=""
IF  lndfh > 0
    nsize =  FSEEK(lndfh, 0, 2)           && Move to EOF
    IF  nsize <= 0
    ELSE
        = FSEEK(lndfh, 0, 0)
        DO WHILE NOT FEOF(lndfh)
            lcparameter=lcparameter+FREAD(lndfh,nsize)
        ENDDO
        *
        cwcofc     = lcparameter
    ENDIF
    =FCLOSE(lndfh)
ELSE
    * Error opening data file
    Wait window "File "+lcdatafile+" do not exists !!" nowait
ENDIF
RETURN lcparameter

function stringtofile
parameter mMystring, lcdatafile     && memo field, output file
lndfh = fopen(lcdatafile)           && you can use fcreate instead of fopen
if  lndfh > 0
    memo_size = memlines(mMystring)
    for i = 1 to memo_size
        m.cLyne   = MLINE(mMystrring, i)
        =fputs(lndfh, m.cLyne)      && depending on how your file is organized you can use fwrite
    endfor
    =FCLOSE(lndfh)
else
    Wait window "File "+lcdatafile+" do not exists !!" nowait
endif
return
HTH


Claudio
"Now to him who is able to do immeasurably more than all we ask or imagine, according to his power that is at work within us, Ephesians 3:20
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform