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

Fetching cyrillic characters from TMemo
Destroy the element that called the onKeyDown event
Keep HTTP- Connection in pascal?
*Dynamic Arrays in Free Pascal
How to convert jpg or png images to dicom format in Lazarus?
Odd sharing access violation (OS Error 32) with Freepascal implementation of libEWF
How can I make my form blur
How to compare string to integer with while do loop in pascal?
Kill a process tree using TProcess
Make a button or menu's caption different from the Action it is linked to?
Rabin Karp Algorithm in pascal
Does Lazarus support TListBox virtual mode?
Quick way to convert widestring LE -> BE
FPC : RTTI on records
Obtaining untyped pointers to procedures
Load .bmp file to Pascal

Categories

HOME
admin-on-rest
jar
amazon-swf
webrtc
facebook-graph-api
ubuntu-16.04
smartphone
thunderbird-addon
formal-verification
google-sheets-api
actionscript
avl-tree
click
wysiwyg
simple-injector
equalizer
lstm
jcl
attask
jquery-scrollify
csh
sumo
skmaps
lync-2013
codelite
dss
system.data.sqlite
google-api-dotnet-client
pep8-assembly
red-black-tree
clockwork
swagger-editor
bing-translator-api
constants
rdw
rapidweaver
pinvoke
multi-agent
instruction-set
in-memory-database
bettercms
laravel-query-builder
sqldatareader
push-diffusion
icefaces
children
console-redirect
search-regex
asp.net-mvc-partialview
void
jta
hornetq
code-readability
team-build
ffserver
harp
cpu-cores
pgm
google-plus-one
es2015
android-search
orientation-changes
moai
fragment-tab-host
ghostdoc
aquafold
config-files
jstack
goinstant
dllexport
execvp
dynamic-binding
threadx
vmware-server
backbone-relational
mstsc
sharpmap
pascals-triangle
lync-server-2010
git-filter-branch
blockingqueue
ninject-extensions
hobo
galaxy-tab
datamember
opengl-es-lighting
zend-form-element
symbol-server
loadui
surefire
hardware-infrastructure

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