how to export a long string into txt file?

icapillaicapilla Member Posts: 30
edited 2012-06-13 in NAV Three Tier
Hi,
I'm trying to export a long string into txt file with a report. I declarated the following local variables :
Cadena1, text 1024
Cadena2, text 1024
Cadena3, text 1024

The section of code where i get the error is the following :

OutFile.WRITE(Cadena1+Cadena2+Cadena3);

When i execute the report, it gets the following error:

"there is not sufficient available space in the c/al stack memory to execute this task.
there are too many simultaneous activities,due to the way recursive function call is used in the program. the problem can by solved temporarily by shutting down some of the open activities(but the function still cannot be executed)."

thank you in advance for your suggestions.

Answers

  • Alex_ChowAlex_Chow Member Posts: 5,063
    Look at the CREATEOUTSTREAM function in NAV. This is what you need.
  • FranklinFranklin Member Posts: 253
    hi Alex Chow!

    I´m a fellow of icapilla.

    We have this code...

    OutFile.CREATEOUTSTREAM(OStream);
    OStream.WRITETEXT(Cadena1+Cadena2+Cadena3);

    But the error continue...

    If i only write this...
    OutFile.CREATEOUTSTREAM(OStream);
    OStream.WRITETEXT(Cadena1+Cadena2);

    the file can be created but if write OStream.WRITETEXT(Cadena1+Cadena2+Cadena3) the error appears..

    The total string is about 2500 characters

    We need some help plz... ](*,)
  • koubekkoubek Member Posts: 84
    Of course you can not add all texts at the same time. This will exceed the limit of NAV string as well. Try this instead (adding by portions):
    MyFile.CREATE('C:\Temp\dump.txt');
    MyFile.CREATEOUTSTREAM(outstrm);
    
    YourCondition := ...;
    
    while (YourCondition) do begin
      TextPortion := 'text portion ';
      OutStrm.WRITETEXT(TextPortion);
    
      YourCondition := ...;
    end;
    
    MyFile.CLOSE;
    
  • ChinmoyChinmoy Member Posts: 359
    Try this:

    OutFile.CREATEOUTSTREAM(OStream);
    OStream.WRITETEXT(Cadena1);
    OStream.WRITETEXT(Cadena2);
    OStream.WRITETEXT(Cadena3);
    OutFile.CLOSE();

    Chn
  • kinekine Member Posts: 12,562
    Or you can write it in Binary mode char by char, in this mode you can write line as long as you want...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • icapillaicapilla Member Posts: 30
    Thanks for your suggestions, my problem it's solved,
    i solved the problem with this sequence of code:
    OutFile.CREATEOUTSTREAM(OStream);
        REPEAT
          CR := 13;
          LF := 10;
          OStream.WRITETEXT(Cadena1);
          OStream.WRITETEXT(Cadena2);
          OStream.WRITETEXT(Cadena3);
          OStream.WRITETEXT(FORMAT(CR) + FORMAT(LF));
        UNTIL VARIABLE.NEXT = 0;
    
  • ChinmoyChinmoy Member Posts: 359
    please don't forget to mark it solved.
Sign In or Register to comment.