Recent

Author Topic: how to write to txt file  (Read 4211 times)

hamza

  • Jr. Member
  • **
  • Posts: 52
how to write to txt file
« on: May 10, 2015, 06:10:26 pm »
hi
how can I write and read single line to text file(file.txt) on linux system??


Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
Re: how to write to txt file
« Reply #1 on: May 10, 2015, 06:14:27 pm »
Just as in Windows:

Code: [Select]
File1:Text;
...
AssignFile(File1,'file.txt');
rewrite(File1);
writeln(File1,'A string to write...');
CloseFile(File1);
...
Var S:String;
...
AssignFile(File1,'file.txt');
reset(File1);
readln(File1,S);
CloseFile(File1);
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: how to write to txt file
« Reply #2 on: May 10, 2015, 06:41:36 pm »
Damn.... Google and Wiki down again at the same time world wide?

http://wiki.lazarus.freepascal.org/File_Handling_In_Pascal

Write:
Code: [Select]
echo This is the line > myfile.txt
Read:
Code: [Select]
cat myfile.txt
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

BitBangerUSA

  • Full Member
  • ***
  • Posts: 183
Re: how to write to txt file
« Reply #3 on: May 10, 2015, 06:51:28 pm »
Quote
Damn.... Google and Wiki down again at the same time world wide?

 :o
Lazarus Ver 2.2.6 FPC Ver 3.2.2
Windows 10 Pro 64-bit

hamza

  • Jr. Member
  • **
  • Posts: 52
Re: how to write to txt file
« Reply #4 on: May 10, 2015, 09:28:14 pm »
loza, thank you

 

TinyPortal © 2005-2018