From bf2450d2cf1dd2f5f45477c0c36d62c8d2dcd931 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Mon, 21 Mar 2022 08:43:37 -0400 Subject: Added option to explicitly specify output file --- driver.f90 | 27 ++++++++++++++++++++++----- fpoint.prj | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/driver.f90 b/driver.f90 index 2521407..2dc6e8a 100644 --- a/driver.f90 +++ b/driver.f90 @@ -28,7 +28,7 @@ implicit none logical::verbose logical::notes integer::i, j, retcode - character(len=:), pointer::filename, arg + character(len=:), pointer::filename, arg, outname if(command_argument_count() < 1) then call usage() @@ -39,7 +39,9 @@ implicit none verbose = .false. notes = .false. filename => null() - do i = 1, command_argument_count() + outname => null() + i = 1 + do while(i <= command_argument_count()) call get_command_argument(i, length=j) allocate(character(len=j)::arg) @@ -51,6 +53,12 @@ implicit none else if(arg == "-v") then verbose = .true. + else if(arg == "-o") then + i = i + 1 + call get_command_argument(i, length=j) + allocate(character(len=j)::outname) + call get_command_argument(i, value=outname) + else filename => arg arg => null() @@ -62,6 +70,8 @@ implicit none arg => null() end if + i = i + 1 + end do if(verbose) then @@ -76,7 +86,13 @@ implicit none call presentation%parse() if((.not. notes) .or. presentation%has_notes()) then - write(*, '(A)') presentation%to_text(notes_only=notes) + if(associated(outname)) then + open(newunit=j, file=outname, action="write", status="unknown") + write(j, '(A)') presentation%to_text(notes_only=notes) + close(j) + else + write(*, '(A)') presentation%to_text(notes_only=notes) + end if else call maybe_print(verbose, "No slide notes found in "//filename) retcode = 1 @@ -115,8 +131,9 @@ contains Print *, " " Print *, "Options:" Print *, " " - Print *, " -n Extract notes instead of slide contents" - Print *, " -v Be somewhat verbose, probably not enough to be interesting" + Print *, " -o Write output to specified filename instead of console" + Print *, " -n Extract notes instead of slide contents" + Print *, " -v Be somewhat verbose, probably not enough to be interesting" Print *, " " Print *, "Output is printed to standard out" Print *, " " diff --git a/fpoint.prj b/fpoint.prj index 038a8ed..f6dab7e 100644 --- a/fpoint.prj +++ b/fpoint.prj @@ -61,7 +61,7 @@ "Launch Using MPI":"false", "Keep Console":"true", "External Console":"true", - "Command Line Arguments":"-n \"Welcome to PowerPoint.pptx\"", + "Command Line Arguments":"-n \"Welcome to PowerPoint.pptx\" -o temp.txt", "Build Before Launch":"true" }, "Build Options":{ -- cgit v1.2.3