-1

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
Denis
  • 79
  • 2
  • 13
  • Fine. And what is your specific question? Please learn [how to ask](http://stackoverflow.com/help/how-to-ask) here! You did not even bother to read the [2-minutres tour](http://stackoverflow.com/tour) to learn how this site is to be used... – aschipfl Oct 19 '16 at 11:51
  • Specific question is "How to pass parameters(values) from .bat file to .prg – Denis Oct 19 '16 at 12:15
  • 1
    Why can't you just use the DATE() function in your programs to get today's date? – Tamar E. Granor Oct 19 '16 at 20:26

2 Answers2

1

Just run VFP9.EXE with the program name and your date.

"c:\Program Files (x86)\Microsoft Visual FoxPro 9\vfp9.exe" myprogram mydate

However the parameter will always be passed as a string, so your program will have to convert it to the correct type.

Alan B
  • 4,086
  • 24
  • 33
0

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.

Cetin Basoz
  • 22,495
  • 3
  • 31
  • 39