freepascal


How do i edit a specific part of a text file in free pascal?


Just as what the title says, how do i do this? I know that the append command adds text to the end of the file but i don't want to do that nor rewrite the entire text file. I just want to edit a specific part of a text file.
Here's my scenario:
I have different lines of data in a text file, what i'm trying to do is to edit a specific line into a user input. What i already have coded down is finding the line to be edited, and then a user input with the data to change on the line and everything works all fine without problems, however i am completely stumped on what i do to change the data from the text file to user input.
Edit: After frustratingly playing around for a while here's what i've come up to, but it doesn't work, error 106.
If s = 'N' Then
Begin
Writeln();
Writeln('Please enter the correct data');
Append(sf);
Readln(sData);
Writeln(sf, sData);
Close(sf);
End;
Also to note, i do not have the file close before this block of code but i do have an EOF to stop the previous code from having unneeded looping before breaking, i close the file at the end of this code and again in another block. Either way the file closes but i only get the error with those block.
Thanks for the comments, using the TStringList procedure my program works the way i want it to.
What i did was load the file with TStringList.LoadFile, and because the data i'm searching through it has a fixed pattern so i was able to search through and indexing through the file with a fixed index (i.e. Index = Index + 3), removed the indexed line in the data file and inserted the new data.

Related Links

Understanding the {$WARN XXXX OFF} compiler directive
How do I output the contents of a Set in Pascal?
exponential form to normal form in pascal
Static code analysis for Free Pascal
How to eliminate Free Pascal 'not recognized' compile error on TFileStream?
Pascal Graph unit - detecting window close
Open a document with Data Point Click or Mark Double Click Lazarus
SQLTransaction2 : Operation cannot be performed on an active transaction FreePascal - Code Typhon
DBGrid doesn't reflect the current dataset status with Zeos components in Lazarus
Lazarus Custom Component - how to return Mouse X,Y to label [closed]
FreePascal: how do I change the colour of a TPaint object on Mouseover
How to get GO32 Unit file of freepascal
Erro code 201 in pascal
Load new scene in GLScene
FreePascal: Identifier not found “MEMW”
How to fix run-time error 201

Categories

HOME
sql-server
batch-processing
plsql
crate
translation
fparsec
playframework
docker-swarm
hana
csvhelper
apollo
couchdb-2.0
propertygrid
schemacrawler
structuremap
flexbox
cortex-a
gwtp
uiview
simple-injector
typeahead
bar-chart
apache-karaf
saiku
eclipselink
zoho
countif
richfaces
philips-hue
iis-10
tampermonkey
entity-system
helix-3d-toolkit
consumer
skygear
hawtio
modelandview
superpowered
von-neumann
nunit-3.0
text-files
axis-labels
floating-accuracy
viewgroup
amd
openweathermap
nsjsonserialization
walmart-electrode
multi-agent
crash-reports
glkit
easing
rstudio-server
aescryptoserviceprovider
freetype2
jackson-databind
database-backups
multilingual-app-toolkit
date-format
logcat
eml
fortran90
drf-nested-routers
persistence.xml
optionbutton
ubercart
ibm-data-studio
lines-of-code
apache-mina
callstack
consensus
pisa
google-admin-audit-api
suffix-array
iostream
mfmailcomposeviewcontroll
logentries
installshield-2011
asp.net-mvc-scaffolding
execvp
apache2.2
nuspec
surveyor-gem
sharpmap
xslkey
arbor.js
moq-3
unions
nintendo
opengl-es-lighting
cookieless
loadui
recordset
external-assemblies
front-controller
multibyte-functions
plinq
outlook-form
web-analytics-tools
writing

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App