A
A
Ashot Aslanyan2022-03-18 17:20:25
Pascal
Ashot Aslanyan, 2022-03-18 17:20:25

How to write pascal result to text file?

Program P42;
 
Procedure Print(Sc : string; S : String);
Var i,l,k : integer;
Begin
    l:=length(Sc);
    for i:=1 to l do Begin
        k:=Ord(Sc[i]);
        write(S[k]);
    End;
    writeln;
End;
 
Procedure Gen(n : integer; S : string);
Var Sc    : String;
Var i,j,p : integer;
Var k,m,f : integer;
Begin
    k:=length(S);
    f:=0;
    Sc:=chr(1);
    for i:=2 to n do Sc:=Sc+Chr(1);
    while (True) do Begin
      Print(Sc,S);
      p:=1;
      while (True) do Begin
         m:=Ord(Sc[p]);
         if m<k then Begin
            Sc[p]:=chr(m+1);
            break;
         end
         else Begin
            if p=n then begin
               f:=1;
               break;
            end;
            Sc[p]:=chr(1);
            p:=p+1;
         end;
      End;
      if f > 0 then break;
    End;
End;
Begin
    Gen(32,'abcdef0123456789'); 
End.


when I launch from below there is an output window. Is there any way to avoid that the result is not shown there, but saved to some text file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HemulGM, 2022-03-18
@HemulGM

Write(file, your text)

K
kalapanga, 2022-03-18
@kalapanga

Working with files in pascal

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question