Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
How to create a txt file from Lazarus?
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Free AI to use in local
by
gidesa
[
Today
at 10:14:48 pm]
Program loop "runaway" wh...
by
Thaddy
[
Today
at 09:34:48 pm]
A "leisure" question on W...
by
EventHorizon
[
Today
at 09:29:50 pm]
Unable to open the packag...
by
LazKuri
[
Today
at 08:42:25 pm]
Your best UI design - con...
by
mgc
[
Today
at 08:33:26 pm]
Slight improvement for la...
by
n7800
[
Today
at 07:18:44 pm]
Controlling the behavior ...
by
1HuntnMan
[
Today
at 04:55:21 pm]
Making panels with lots o...
by
lainz
[
Today
at 04:00:20 pm]
Ribbon bar in Lazarus 3.2...
by
lainz
[
Today
at 03:58:42 pm]
Have anyone develop UEFI ...
by
PascalDragon
[
Today
at 02:16:40 pm]
Dynarray initialization p...
by
PascalDragon
[
Today
at 02:12:47 pm]
STARS and Regular POLYGON...
by
Boleeman
[
Today
at 02:05:38 pm]
how to change the color f...
by
cdbc
[
Today
at 12:02:27 pm]
Understanding and adjusti...
by
ArchChem
[
Today
at 11:49:35 am]
Offical launch of the 1 B...
by
abouchez
[
Today
at 11:14:35 am]
Using KeyPress event, how...
by
KodeZwerg
[
Today
at 10:44:31 am]
Big Numbers Math
by
Thaddy
[
Today
at 07:22:49 am]
Parquet?
by
Thaddy
[
Today
at 07:11:17 am]
Project fails on run but ...
by
jamie
[
Today
at 12:54:49 am]
Curling Pythagoras Tree: ...
by
Boleeman
[
Today
at 12:00:37 am]
how to search in rxmemory...
by
rcmz
[March 28, 2024, 10:19:54 pm]
Configure JCF messages
by
GordonFindlay
[March 28, 2024, 10:16:19 pm]
Poll: Watches and Display...
by
Martin_fr
[March 28, 2024, 10:15:08 pm]
Dialog ShowModal and an i...
by
d7_2_laz
[March 28, 2024, 09:51:39 pm]
JEDI error but unit compi...
by
Thaddy
[March 28, 2024, 09:30:33 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to create a txt file from Lazarus? (Read 1105 times)
Jvan
Full Member
Posts: 181
How to create a txt file from Lazarus?
«
on:
September 29, 2020, 09:57:02 pm »
How to create one and to delete it after?
Thanks.
Logged
Handoko
Hero Member
Posts: 5132
My goal: build my own game engine using Lazarus
Re: How to create a txt file from Lazarus?
«
Reply #1 on:
September 29, 2020, 10:14:22 pm »
You can use
FileCreate
(then FileWrite):
https://www.freepascal.org/docs-html/rtl/sysutils/filecreate.html
Or
In the link below go the the
File handling
section, there you can find
Text file demo
and
Text File Demo #2
also
improve performance
in the
General
section:
https://wiki.freepascal.org/Portal:HowTo_Demos
To delete a (text) file, you can use
DeleteFile
command:
https://www.freepascal.org/docs-html/rtl/sysutils/deletefile.html
Others useful reading materials:
https://wiki.freepascal.org/Files
http://www.pascal-programming.info/lesson8.php
https://wiki.freepascal.org/File_Handling_In_Pascal
«
Last Edit: September 29, 2020, 10:33:39 pm by Handoko
»
Logged
howardpc
Hero Member
Posts: 4144
Re: How to create a txt file from Lazarus?
«
Reply #2 on:
September 29, 2020, 11:32:38 pm »
You could also use the TStringList class which provides a SaveToFile() method.
You can use DeleteFile() to remove a file.
Logged
Bart
Hero Member
Posts: 5275
Re: How to create a txt file from Lazarus?
«
Reply #3 on:
September 29, 2020, 11:35:03 pm »
Old school:
AssignFile()
Rewrite()
CloseFile()
Bart
Logged
lainz
Hero Member
Posts: 4463
Re: How to create a txt file from Lazarus?
«
Reply #4 on:
September 30, 2020, 01:24:54 am »
I do this when debugging a program with text files...:
Code: Pascal
[Select]
[+]
[-]
with
TStringList
.
Create
do
begin
try
Add
(
'Some variable:'
+
IntToStr
(
somenumber
)
)
;
SaveToFile
(
'file.txt'
)
;
finally
Free
;
end
;
end
;
I delete the file myself after checking it... but you can delete it as here was explained by the other forum members.
Logged
https://lainz.github.io/
Jvan
Full Member
Posts: 181
Re: How to create a txt file from Lazarus?
«
Reply #5 on:
September 30, 2020, 04:09:11 am »
Thanks!
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
How to create a txt file from Lazarus?
TinyPortal
© 2005-2018