Search code examples
batch-filevbscriptcmdvisual-foxprofoxpro

Pass parameters from BAT file OR VBS to Visual Fox Pro (.prg files)


I have many .prg files which I'm currently using daily. One of the parameters which I have to type in manually is todays date.

The idea is that, as example, date will be as parameter in .bat or .vbs file and when I run bat or vbs... it will pass parameters to .prg file and excecute the .prg file with set parameter.

OR something like this...in CMD

set date=20161019 do "n:\xxx\xxxx\xxx\xx\xx\xxxxx\ccc_ass.prg" date

Solution

  • You can simply pass your date as a string (parameters are always passed as a string). When doing that, always use a format that is free from date settings and would be interpreted the same way. IOW make it in yyyy/MM/dd format. ie:

    -The .prg

    lparameters theDateStr
    local ldDate
    if !empty( m.theDateStr )
       ldDate = cast( '^' + m.theDateStr as Date)
    else
       ldDate = {}
    endif
    *...
    

    and call it like (23 Oct 2016):

    vfp.exe yourprogram.prg 2016/10/23
    

    OTOH, why instead of editing a BAT file and calling via a BAT, why don't you edit the prg itself, or let prg get the date from an external source.