I have a text-file where I need to replace a given string to something else. The problem is that the lines in this text-file are > 1024 characters, so I can't use recFile.READ(txtLine) to read this file line by line.
Is it possible with STREAMS to read this file, search for the string, replace it with another value, and write it back to the file? Can someone post some C/AL Code please?
No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
0
Comments
Name DataType Length
FTPUploadLog File
FTPUpLoadLogIStream InStream
FTPUploadLogTextLine Text 1024
//Open the upload log to check the file upload status
FTPUploadLog.TEXTMODE(TRUE);
IF NOT FTPUploadLog.OPEN(EDITradingPartnerDoc."Document Folder" + 'FTPUploadLog.txt') THEN BEGIN
FOR i := 1 TO 10 DO BEGIN
SLEEP(5000);
IF FTPUploadLog.OPEN(EDITradingPartnerDoc."Document Folder" + 'FTPUploadLog.txt') THEN
i := 11;
END;
END;
FTPUploadLog.CREATEINSTREAM(FTPUpLoadLogIStream);
UploadError := TRUE;
IF FTPUploadLog.LEN > 0 THEN
REPEAT
IF FTPUpLoadLogIStream.READTEXT(FTPUploadLogTextLine) > 0 THEN BEGIN
FTPLog.WRITE(FTPUploadLogTextLine);
IF COPYSTR(FTPUploadLogTextLine, 1, 3) = '226' THEN
UploadError := FALSE;
END;
UNTIL FTPUpLoadLogIStream.EOS;
If it occurs more than once in a line (a "line" is a text string ending in CRLF) you want each occurace replaced correct?
If you have a working routine developed - why not just call it twice with the second call using a seek of let say 500 to capture the strings on the 1023 - 1025 overlap.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
variables:
wordInt, posInt,toReturns (Integers)
char (Text len 1)
fiel File
inStream inStream
replacing the string however seems more challenging...
This needs to be re-written it's very crude, but it has my idea. Plus I'm getting some strange character written in textfile2 - 00h?
I like jreynolds' idea of pulling it into a bigtext and operating on it. When I get more time I'm going to have to investigate that route.
Genius function! Using the BigText variables is elegant and works like a charm. I had no idea the BigText variable had that functionality.
MCP - MBS Navision
jle@naviworld.com
use
charTab := 9;
FORMAT(charTab);
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html