mibuso.com

Microsoft Business Solutions online community
It is currently Wed Nov 26, 2014 5:06 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Using BigText
PostPosted: Mon Mar 19, 2012 1:38 am 
Offline

Joined: Fri Jul 15, 2011 3:49 pm
Posts: 34
Country: Canada (ca)
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;


Top
 Profile E-mail  
 
 Post subject: Re: Using BigText
PostPosted: Tue Mar 20, 2012 10:46 am 
Online
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Wed Jul 02, 2003 9:13 am
Posts: 7705
Location: Milan
Country: Italy (it)
try this:


Code: Select all
// 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
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2014 - 20 & 21 November 2014 ««« Visit the conference website: http://www.navtechdays.com


Top
 Profile  
 
 Post subject: Re: Using BigText
PostPosted: Tue Mar 20, 2012 8:10 pm 
Offline

Joined: Fri Jul 15, 2011 3:49 pm
Posts: 34
Country: Canada (ca)
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


Top
 Profile E-mail  
 
 Post subject: Re: Using BigText
PostPosted: Thu Mar 22, 2012 8:07 am 
Online
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Wed Jul 02, 2003 9:13 am
Posts: 7705
Location: Milan
Country: Italy (it)
try this:
Code: Select all
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
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2014 - 20 & 21 November 2014 ««« Visit the conference website: http://www.navtechdays.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Google [Bot] and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: