3

I know my question is rather generic (and it looks like "please do all of my work for me"), so let me make it somewhat clearer: I'm - more or less - a COBOL beginner, the only thing I've done with it so far was a small FastCGI application for a single-serving page, just to have done something with it.

Now I'm considering to write a small file server in GnuCOBOL so I have something real to work with. I tend to learn new languages by writing stuff in them. While I do have an idea about how to read and process a specific file now, I still could need a clue about how I can collect and handle a specified directory's contents.

Sadly, the system calls C$LIST-DIRECTORY,x"91" function 69, CBL_DIR_SCAN_START and its sibling methods are still on the GnuCOBOL Wish List, so I can't just adapt existing solutions from the commercial COBOLs. I'm somewhat lost here.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
jekyll
  • 78
  • 1
  • 10
  • Perhaps a better place to raise this is on the GnuCOBOL Discussion pages at SourceForge.Net. I'm not sure a small file server is an ideal way to learn COBOL, although your first foray into COBOL sounds interesting (there is a Contributions area on the GnuCOBOL site, and you may want to consider presenting that to a wider audience there). Anyway, it would be easier to discuss such things at the GnuCOBOL site. – Bill Woodger Aug 16 '16 at 16:13
  • Using languages for what they were made for is not an interesting task ... ;-) OK, I'll see if I can find my SourceForge credentials again. I was just hoping the audience here would be larger. Thank you, though! – jekyll Aug 16 '16 at 18:36
  • Fair enough. I don't want to discourage you :-) – Bill Woodger Aug 16 '16 at 18:37
  • What operating system? GnuCOBOL is, in some ways, a lot like C. `CALL` the system services that you have available. Or, include something like cobweb-pipes and open a reader to `ls` with user defined functions. `move pipe-open("ls", "r") to pipe-record ... perform until done ... move pipe-read(pipe-record, line-buffer) to pipe-transient ... move pipe-close(pipe-record) to pipe-status` – Brian Tiffin Aug 17 '16 at 03:11
  • I develop the software mostly on Windows but I plan to use it mainly on BSD later. Well, I planned to - but I can guess from your answer that platform-independent solutions are not easily possible here? :-( – jekyll Aug 17 '16 at 08:13

1 Answers1

1
call "system" using "dir /b > fileslist.txt" end-call

And then read in the listing file ...