2

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?

Mike Fechner
  • 6,627
  • 15
  • 17
NudeDude
  • 25
  • 4

2 Answers2

3

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))) .
             
Mike Fechner
  • 6,627
  • 15
  • 17
  • Why do you use here **VALUE** ? For some reason it doesnt work when i use os-command value but os-command silent works well. ( Local ). I use the **silent** because i want it to run in background so i dont want to see console window when it executed. Is it True to use _silent_ in this way ? – NudeDude Mar 01 '21 at 15:47
  • I use VALUE to support a runtime evaluated expression. Without VALUE, SUBSTITUTE function would be interpreted as the command and not as an expression that returns the OS command. You can combine SILENT and VALUE: OS-COMMAND SILENT VALUE (...) – Mike Fechner Mar 01 '21 at 19:31
0

Long, long time since I did any Progress, so I've no recollection of how os-command works, but I'd try

os-command("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)

Theory : quoting the full executable-name should be interpreted as a single token. possibly the ) in x86) would need to be escaped with ^ , ie. x86^)

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • It works locally with single quotes at the beginning and then each Parameter double quotes -->`os-command (' "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" ')` – NudeDude Mar 01 '21 at 15:01
  • but why this doesnt work if i use variable instead constant like `01.03.2021` and `09.17.25` ----> `x="01.03.2021" y="09.17.25" ` `os-command(' "C:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe" "K:\K11\WEB\PDF\Name_' x '_' y '_xx.html" "K:\K11\WEB\PDF\Name_' x '_' y '_xx.pdf" ')` – NudeDude Mar 01 '21 at 15:07
  • this is another option with substitute but this one doesnt work also : `OS-COMMAND SILENT SUBSTITUTE (' "C:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe" "K:\K11\WEB\PDF\Name_&1_&2_&3.html" "K:\K11\WEB\PDF\Name_&1_&2_&3.pdf" ', "01.03.2021", "14.09.30", "xx")` – NudeDude Mar 01 '21 at 15:44