Using BigText
fazlehasan
Member Posts: 71
I was trying to read a text file to count the lines of the file:
unfortunately
each line in the file has more then 1024 characters
so i used BigText to read the file:
WorkFileL.OPEN(FileNameP);
WorkFileL.TEXTMODE := TRUE;
WHILE WorkFileL.POS < WorkFileL.LEN DO BEGIN
IF WorkFileL.READ(BigTextL) <> 0 THEN;
LinesL += 1;
END;
EXIT(LinesL);
I have used InStreams and OutStreams and all the functions available for BigText
without success: I could not read the BigTextL variable, can anyone help please?:
IF WorkFileL.READ(BigTextL) <> 0 THEN REPEAT
//BigTextL.ADDTEXT(BigTextL);
TempItemRecL.INIT;
TempItemRecL."No.":='test_test';
TempItemRecL.Picture.CREATEOUTSTREAM(OstreamL);
BigTextL.WRITE(OstreamL);
TempItemRecL.INSERT;
TempItemRecL.GET('test_test');
TempItemRecL.CALCFIELDS(Picture);
IF TempItemRecL.Picture.HASVALUE THEN BEGIN
ItemRecL.Picture.CREATEINSTREAM(IstreamL);
BigTextL.READ(IstreamL);
WHILE NOT (IstreamL.EOS()) DO
BEGIN
IstreamL.READTEXT(WorkTextLineL);
END;
END;
TempItemRecL.DELETE;
//BigTextL.GETSUBTEXT(WorkTextLineL, 1, 1024);
CLEAR(BigTextL);
IF STRLEN(WorkTextLineL)>0 THEN BEGIN
... ...
//WorkTextLineL is a String so any String function I can use now
// but I am getting WorkTextLineL='';
... ...
END;
unfortunately
so i used BigText to read the file:
WorkFileL.OPEN(FileNameP);
WorkFileL.TEXTMODE := TRUE;
WHILE WorkFileL.POS < WorkFileL.LEN DO BEGIN
IF WorkFileL.READ(BigTextL) <> 0 THEN;
LinesL += 1;
END;
EXIT(LinesL);
I have used InStreams and OutStreams and all the functions available for BigText
without success: I could not read the BigTextL variable, can anyone help please?:
IF WorkFileL.READ(BigTextL) <> 0 THEN REPEAT
//BigTextL.ADDTEXT(BigTextL);
TempItemRecL.INIT;
TempItemRecL."No.":='test_test';
TempItemRecL.Picture.CREATEOUTSTREAM(OstreamL);
BigTextL.WRITE(OstreamL);
TempItemRecL.INSERT;
TempItemRecL.GET('test_test');
TempItemRecL.CALCFIELDS(Picture);
IF TempItemRecL.Picture.HASVALUE THEN BEGIN
ItemRecL.Picture.CREATEINSTREAM(IstreamL);
BigTextL.READ(IstreamL);
WHILE NOT (IstreamL.EOS()) DO
BEGIN
IstreamL.READTEXT(WorkTextLineL);
END;
END;
TempItemRecL.DELETE;
//BigTextL.GETSUBTEXT(WorkTextLineL, 1, 1024);
CLEAR(BigTextL);
IF STRLEN(WorkTextLineL)>0 THEN BEGIN
... ...
//WorkTextLineL is a String so any String function I can use now
// but I am getting WorkTextLineL='';
... ...
END;
0
Comments
-
try this:
// define the CR/LF chars to search for crlf := 'xx'; crlf[1] := 10; crlf[2] := 13; // I was too lazy to create a file, so I just threw something in the bigtext (you need to read the complete file in the bigtext) bgt.ADDTEXT('I' + crlf + 'pust' + crlf + 'put' + crlf + 'something' + crlf + 'in'); // and now I just search for the no. of CR/LF's in the bigtext // REMARK: the content of the bigtext will be destroyed by the search, so if you still need it, save it first in // another bigtext NoOfLines := 1; i := bgt.TEXTPOS(crlf); WHILE i > 0 DO BEGIN NoOfLines += 1; bgt.GETSUBTEXT(bgt,i + 1); if bgt.LENGTH > 2 then i := bgt.TEXTPOS(crlf) else i := 0; END; MESSAGE('%1',NoOfLines);Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
thanks kriki for your reply...
may be i could not clearly state my problem...
i could count the lines
i could load each line of the .txt file in the BigText variable
but I could not use it ...
I need to grab the first 1024 character of the BigText variable
for various String manipulation
which I could not do...
tried all the available functions of BigText - without success
thanks again0 -
try this:
MESSAGE("No. Of Chars copied:%1",bgt.GETSUBTEXT(First1024Chars,1,maxstrlen(First1024Chars)));Too see how many chars are really copied.
IF First1024Chars = '', it is possible that you only had blanks in the first 1024 positions.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions