use acc_log scatter to flist m_total=alen(flist) fp=fcreate("new.txt") if ferror()=-1 dialog box "The file could not be created." else for n=1 to m_total fwrite(fp,flist[n],80) next endif fclose(fp) if ferror()=-1 dialog box "The file could not be closed." endif
https://www.lianja.com/doc/index.php/FCREATE()
use accounts scatter to flist m_total=alen(flist) fp=fcreate("new.txt") if ferror()=-1 dialog box "The file could not be created." else for n=1 to m_total fwrite(m->fp,flist[n],80) next endif fclose(fp) if ferror()=-1 dialog box "The file could not be closed." endif
https://www.lianja.com/doc/index.php/FCLOSE()
open database southwind use example fp=fcreate("names.txt") count=0 do while not eof() count = count + fputs(fp,trim(last_name) + ", "+trim(first_name)) skip enddo fclose(fp) echo str(count,5) + " bytes written.\n" fp = fopen("names.txt") count = 0 do while not feof(fp) if left(fgets(fp),5) = "Smith" ++count endif enddo fclose(fp) echo str(count,5) + " Smiths found.\n" close databases
https://www.lianja.com/doc/index.php/FGETS()
open database southwind use example fp=fcreate("names.txt") count=0 do while not eof() count = count + fputs(fp,trim(last_name) + ", "+trim(first_name)) skip enddo fclose(fp) echo str(count,5) + " bytes written.\n" fp = fopen("names.txt") count = 0 do while not feof(fp) if left(fgets(fp),5) = "Smith" ++count endif enddo fclose(fp) echo str(count,5) + " Smiths found.\n" close databases
https://www.lianja.com/doc/index.php/FPUTS()
fp = fopen("names.txt") ?fread(fp,80) Smith,Bill fclose(fp)
https://www.lianja.com/doc/index.php/FREAD()
use accounts fp=fopen("existing.txt") if ferror()=-1 dialog box "The file could not be opened." else string = freadstr(fp,80) do while not empty(string) ? string string = freadstr(fp,80) enddo endif fclose(fp) if ferror()=-1 dialog box "The file could not be closed." endif
https://www.lianja.com/doc/index.php/FREADSTR()
fp = fopen("names.txt") string = fgets(fp) fseek(fp, 1024,0)
https://www.lianja.com/doc/index.php/FSEEK()
fp=fcreate("time.txt") if ferror()=-1 dialog box "The file could not be created." else fwrite(fp,timestamp()) endif fclose(fp) if ferror()=-1 dialog box "The file could not be closed." endif
https://www.lianja.com/doc/index.php/FWRITE()
use accounts fp=fopen("existing.file") if ferror()=-1 dialog box "The file could not be opened." else string = fgets(fp) do while not empty(string) ? string string = fgets(fp) enddo ? endif fclose(fp) if ferror()=-1 dialog box "The file could not be closed." endif // http URL example
<!-- twitter.rsp --> <html> <body> <% fp=fopen("http://twitter.com/recitalsoftware") do while not feof(fp) ? fgets(fp) enddo fclose(fp) %> </body> </html>
https://www.lianja.com/doc/index.php/FOPEN()
open database southwind use shippers copy to ship.txt type csv fd=fopen("ship.txt") do while .t. cGetLine = fgets(fd) if feof(fd) exit else // process endif enddo fclose(fd)
https://www.lianja.com/doc/index.php/FEOF()
use accounts fp=fopen("existing.file") if ferror()=-1 dialog box "The file could not be opened." else string = freadstr(fp,80) do while not empty(string) ? string string = freadstr(fp,80) enddo ? fclose(fp) if ferror()=-1 dialog box "The file could not be closed." endif endif
https://www.lianja.com/doc/index.php/FERROR()
fwrite(fp,"Hello World") fflush(fp)
https://www.lianja.com/doc/index.php/FFLUSH()