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

Three digits real number in Pascal
Free Pascal terminal IDE fp seems not to compile with fpc
Increase speed of a tight loop with little action :)
How do I detect if stdin or stdout is redirected in FreePascal under Windows?
FPC 3.0.0 how to connect to Postgresql 9.3 using TPQConnection, TSQLTransactio, TSQLQuery
Free-Pascal Implementation of the Sieve of Eratosthenes
How do you determine the exception being thrown by MkDir?
Access Violation when trying to allocate memory to a pchar
How to read gvfs file by TStream
Why Free Pascal prints 'NO'?
Pascal : write a very long string without reference-counted types (ex:ansistring)
How to get TFPGList pointer to item?
Make compact list of records in FreePascal?
FreePascal: find lines where “= overload” is used
Error: duplicate case label free pascal compiler
How to port app from Borland Pascal to FreePascal and Unicode terminal

Categories

HOME
paypal
puzzle
wmic
ncurses
webrtc
jbehave
decorator
mapbox-gl-js
windows-store-apps
survival-analysis
i2c
jframe
google-plus
packer
keystore
cockroachdb
xul
informatica-powercenter
medium-editor
bootstrap-popover
redux-observable
chocolatey
ejbca
device-detection
header-files
source-maps
pipelinedb
onesignal
osmdroid
ui5
hawtio
data-extraction
fabric-digits
recurrence-relation
remote-server
redhat-datavirt
freetts
duktape
active-model-serializers
restful-url
ddms
jupyter-console
dojox.mobile
scalafx
rich-text-editor
bids
tableau-server
appstore-approval
tiddlywiki
decompress
ticker
tofixed
httplib2
infinite-scroll
uicollectionviewlayout
collapsingtoolbarlayout
emoticons
ingres
barcode-printing
software-product-lines
dts
spring-lemon
asp.net-mvc-partialview
insertion-sort
insert-into
windowlistener
integral
connection-reset
inputaccessoryview
libsndfile
gyroscope-framework
formvalidation-plugin
snmp4j
dto
outline
coin-flipping
ssms-addin
resource-files
internal
hamsterdb
symphony-cms
pep8
fluidsynth
linkedhashset
web-safe-fonts
scrollto
xmlslurper
v4l
scraperwiki
django-nose
collect
phpcrawl
adobe-contribute
requestfactory
graniteds
openvg
integer-promotion
self-reference





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