• Directory Contents in pascal

    From Tiny@618:618/12 to All on Wed Oct 30 07:07:35 2024

    Hello everybody!

    Does anyone have an example of pascal source code to just display the
    contents of a directory? I can do it with a shell to dir /b d:\blah but looking for a way that I could make pretty.

    I don't need to edit it or select it etc. Just display the directory.

    This is what I'm using now:
    Exec(GetEnv('COMSPEC'), '/C dir /b d:\outbound');

    It works, but not pretty and it seems to over write anything I want to display first.

    ---
    * Origin: Dirty Ole Town (618:618/12)
  • From Nick Andre@618:500/24 to Tiny on Wed Oct 30 09:25:50 2024
    On 30 Oct 24 07:07:35, Tiny said the following to All:

    Does anyone have an example of pascal source code to just display the contents of a directory? I can do it with a shell to dir /b d:\blah but looking for a way that I could make pretty.

    Yes.

    program dirthis;
    uses dos;

    var dirinfo : SearchRec;
    this : string;

    procedure DirThisFile;
    begin
    writeln(dirinfo.name);
    end;

    begin
    writeln('Dir "This" Win32 Copyright (c) by Nick J. Andre, Ltd.');
    writeln;
    this:=paramstr(1);
    if (pos('\',this)=0) or (this[length(this)]<>'\') then this:=this+'\';
    if (pos('.',this)=0) and (pos('*',this)=0) then this:=this+'*.*';
    findfirst(this,archive,dirinfo);
    if DOSerror=0 then DirThisFile;
    while (DOSerror=0) do
    begin
    findnext(dirinfo);DirThisFile;
    end;
    findclose(dirinfo);
    end.

    Nick

    --- Renegade vY2Ka2
    * Origin: Joey, do you like movies about gladiators? (618:500/24)
  • From Shawn Highfield@618:618/12 to Nick Andre on Wed Oct 30 17:35:04 2024
    Nick Andre wrote in a message to Tiny:

    Does anyone have an example of pascal source code to just display the
    Yes.

    program dirthis;

    Thank you Sir. I'll play in the debugger a bit, it repeats the last file a second time which is not a huge issue for me.

    However it hates the directory D:\outbound.26a (as an example) so I'll work on that too. lol I am a bit rusty with this stuff, but having fun.

    Again thanks for pointing me in the right direction!

    Shawn
    ... If you want your boomerang to come back, throw it first!
    --- timEd 1.10.y2k+
    * Origin: Dirty ole' Town (618:618/12)
  • From Sean Dennis@618:618/1 to Shawn Highfield on Wed Oct 30 21:06:12 2024
    Does anyone have an example of pascal source code to just display the

    I asked Microsoft Copilot your question and it gave me this:

    program ListDirectory;

    uses
    Dos;
    var
    SR: SearchRec;

    begin
    Writeln('Directory contents:');
    FindFirst('*.*', Archive, SR);
    while DosError = 0 do
    begin
    Writeln(SR.Name);
    FindNext(SR);
    end;
    end.

    It seems to work here okay.

    -- Sean




    --- MBSE BBS v1.1.0 (Linux-x86_64)
    * Origin: Outpost BBS * Johnson City, TN (618:618/1)
  • From Tiny@618:618/12 to Sean Dennis on Thu Oct 31 07:02:00 2024
    Hi Sean,
    On <Thu, 30 Oct 24>, you wrote me:

    I asked Microsoft Copilot your question and it gave me this:

    I don't use AI if I can help it. I'm not a crazy person about it just
    I'd rather not give skynet a chance, and if I'm the one hold out that
    will stop AI from taking over I will die a happy man.

    program ListDirectory;

    However thank's. I'll save it and if I use it I'll credit you. hahahaha

    Shawn

    --- Grumble
    * Origin: This time everything is easy (618:618/12)