Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fopen( ) and Fwrite( ) usage
Message
From
24/07/2001 06:35:41
 
 
To
24/07/2001 06:24:57
Jimi Lee
Pop Electronic Products Ltd.
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00534274
Message ID:
00534277
Views:
18
This message has been marked as the solution to the initial question of the thread.
>hi everyone,
>
>what is the problem of following code? i can open and get the values, but can't write the new value back to the file:
>
>there is only 5 bytes in Number.dat: " 1234".
>
>FileID=fopen("Number.dat")
>if FileID <> -1 then
>  tempStr=fgets(FileID, 40)
>  tempNum=val(tempStr)
>  tempStr=padl(allt(str(tempNum+1)), 5, " ")
>  fwrite(FileID, tempStr) && return 0 at this line, i.e. can't write
>endif
>
>
>I have tried fwrite(FileID, "tempStr") and fwrite(FileID, &tempStr), both not work.
>
>thanks in advance!

fopen defaults to open for read-only, use fopen("Number.dat", 2 ) for buffered read/write or fopen("Number.dat", 12 ) for unbuffered read/write.
Len Speed
Previous
Reply
Map
View

Click here to load this message in the networking platform