Hi guys,
i've looked up and down this forum many times, but i still haven't found what i was looking for.
I've got a text file, like this.
aaaaaaaaa
bbbbbbbbb
ccccccccc
ddddddddd
eeeeeeeee
I need to rewrite the 3rd line. Something like this :
aaaaaaaaa
bbbbbbbbb
ppp
ddddddddd
eeeeeeeee
Well. I know how to place the pointer in the right position (TEXTMODE = FALSE, file.SEEK(Position) ) but i've got problems when it comes to write my string.
My code is (example) :
linelength : integer;
index : integer;
string : text[100];
string := 'ppp';
FOR index := 1 TO LineLength
File.WRITE(string[index]);
The point is : i wanted to avoid inserting CRLF at the end of my line. It worked, but the result wasn't so good.
aaaaaaaaa
bbbbbbbbb
p p p ccccccccc (as you can see, the old line is still there)
ddddddddd
eeeeeeeee
Furthermore, openin my text file with WordPad i see that after every single char appears a strange "square symbol" (i think you know what i mean)... using NotePad it's just a space.
So... i need your help guys !
Thank you !!
Franco
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Thanks for replying. The fact is i've already thought about it, and i can't do it. The text file i'm using is a shared file. A second software is using it so i can't delete/replace it.
(by the way, i asked them..the answer wasn't what i wanted. Maybe it's just lazyness..but my hands are tied...)
Thank you anyway.
Franco
In these days using file as place for exchanging the information is not way how to do that.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I know! That's exactly what i told them! I feel like i'm still living in the middle age of IT! Bleah!
:?
viewtopic.php?f=23&t=29313&p=146950#p146950
That example doesn't do what i need - it replaces a string you're already supposed to know -anyway, it gives me an idea.
1. I can read the line in the position i need to replace.
2. Save the value of this line inside a global (bigtext).
3. Search for this line inside the file (maybe using the example in the link).
4. Replace the target line with a new one.
I'll try, then i'll let you know.
Thank you
still having the same old problem. Using two different text files the result is ok, but not good for my purpose : i must use the same file without copy, delete or rename.
](*,)
(just went to see the ascii table, perhaps go to the end of the line and write the backspace char (8))
|To-Increase|
Using two File variables. One for reading (FileR), one for reading/writing (FileRW). Open same file with both. Set the FileR after the text you want to change. Set the FileRW to the position of the change, write the new part. After that read everything from FileR and write it into FileRW. After all is read from FileR, use FileRW.TRUNC to truncate rest of the file.
You need to think about the problem in his way: you can only "overwrite" the data in the file, you cannot remove part of them. The additional part you want to "remove" must be overwritten with the rest of the file, you can only truncate the end of the file.
But I do not know, if it will works when the replaced part is shorten than the inserted one (whn the FileR will read on modified par by FileRW).
I hope that you catch what I tried to describe... 8)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Just wanted to say that this is an excellent post. I never used BigText before. But after seeing this code example, I will use it more now.