Using BigText

fazlehasanfazlehasan Member Posts: 70
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;

Comments

  • krikikriki Member, Moderator Posts: 9,112
    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!


  • fazlehasanfazlehasan Member Posts: 70
    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 again
  • krikikriki Member, Moderator Posts: 9,112
    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!


Sign In or Register to comment.