Search code examples
batch-fileexewkhtmltopdfopenedgeprogress-4gl

How to run .exe/.bat file with INPUT/OUTPUT in Progress 4GL


I try to create a PDF-File via wkhtmltopdf.exe in Progress4GL. I have written a procedure which downloads a html file as an INPUT.

procedure downloadhtml:

    define input parameter i-benutzer as character  no-undo.

    
    define variable zw-path         as character no-undo.
    define variable h-uhrzeit       as character no-undo.
    define variable h-text          as character no-undo.    
    

    h-uhrzeit = string(time, "HH:MM:SS").
    h-uhrzeit = replace(h-uhrzeit, ":", "."). 
   
    h-text = '<div style="color:red;">I am a html file</div>'.
   
    
    find database.table
         where database.table.man     = "xxx"
         and   database.table.krg     = "X-2540.w"
         and   database.table.user    = "_PPS"
         and   database.table.opzt    = "_PPN"
         no-lock no-error.
    if available database.table then do:
       zw-path = table.field.
    end.

 
    OUTPUT TO VALUE(zw-path + "Name_" + string(today,"99.99.9999") + "_" + h-uhrzeit + "_" + i-benutzer + ".html").
  
    
        put unformatted h-text skip.
   
    
    output close.

end procedure.

It downloads the html file to this directory :

K:\K11\WEB\PDF\Name_01.03.2021_09.17.25_xx.html

wkthmltopdf.exe has 1 INPUT and 1 Output Directory. Structure looks like this in CMD Console --> :: [.exe] [INPUT DIRECTORY] [OUTPUT DIRECTORY]

if I run manually cmd console with these commands it works perfectly

cd C:\Program Files (x86)\wkhtmltopdf\
wkhtmltopdf.exe K:\K11\WEB\PDF\Name_01.03.2021_09.17.25_xx.html K:\K11\WEB\PDF\Name_01.03.2021_09.17.25_xx.pdf

My Question is: How can I run .exe File with dynamic(Name depends on Date&Time) INPUT OUTPUT Variables in Progress ?

I found a command which runs .exe file in progress4GL

os-command(wkhtmltopdf.exe) 

but how can I put input and output variables/directories in .exe file in progress4gl?


Solution

  • Something like

        OS-COMMAND VALUE (SUBSTITUTE ("cd C:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe K:\K11\WEB\PDF\Name_&1.&2.&3.html",
                                      DAY (TODAY),
                                      MONTH (TODAY),
                                      YEAR (TODAY))) .