|
Answer» Hi. I have to do the following in a batch file:
Accept two date parameters in the main batch file from a user. validate these for the proper format and then pass it to another batch file to execute a stored procedure.
Can any help me in this regards??
azzafWhat do you mean "date parameters"? What is the "proper format"? If I have values/strings that I need to use inanother bacth file, I usally echo them to a txt file and input them back in.
example
batch 1 some code to generate the value of xxx
echo xxx >>c:\value.txt
batch 2
set value= del c:\value.txt
just one thing you should know, doing it LIKE this will only allow you to use the top line of the txt file. nice.The receiving batch file receives the parameter using the % reference in a program such has Basic it would be:
RUN "Parent.bat " ............etc
Parent.bat would refer to the parameters using the % SYMBOL:
echo off if not "%1"=="expected1" GOTO :FirstError if not "%2"=="expected2" goto :SecError
echo pModtime pModdate > fileout.txt
goto :end :FirstError echo First parameter receivced in error > fileout.txt goto :end :SecError echo Second parameter received in error > fileout.txt :end
fileout gets picked up by any program, and it would be read as a line input type of file handle, that is, with expected CHR(13)chr(10) following the date and time info. DOS already places these characters after the data WRITE.
you would need to forewarn the programmer to expect an exception output if there was an error ie: "(x) parameter received in error".
alternatively, you can include a termination code as parameter #1, then your info, or failure message:
echo 1 DateMod1 TimeMod2 > fileout.txt
1 being a successful conversion.
*************************************************8
oops!, You wanted to go to another batch file. Try this.
NewMod.bat pModtime pModdate
or: NewMod.bat 1 pModtime pModdate
Andy
|