You are not logged in.
I have a batch file myfunct.bat for storing user defined functions. It has following format:
:funct1
:: My function1 here
SET par1=%%1
SET par2=%%2
SET par3=%%2
GOTO:EOF
:funct2
:: My function2 here
SET par1=%%1
SET par2=%%2
SET par3=%%2
GOTO:EOF
:funct3
:: My function2 here
SET par1=%%1
SET par2=%%2
SET par3=%%2
GOTO:EOF
I would like to use my functions in another batch file. (Something like loading package or library.)
I'm trying to use variations of of following but without success:
CALL myfunct.bat :label <par1> <par2> <par3>
I know it works if the functions are pasted in the same bat file from which they are called.
Is there a simple way to do it?
One solution which occurred to me is to append all functions from myfunct.bat. (myfunct.bat >> mycurrent.bat)
I would have to check if the functions are already appended or delete them before appending.
Offline
The easiest way would be to have your library script take in parameters and have the first line be
call :%1 %2 %3 %4
where %1 is the function and %2-4 are the parameters of that function
Then, when your main script calls the library script, you just use
call library.bat function param1 param2 param3
Offline
The easiest way would be to have your library script take in parameters and have the first line be
call :%1 %2 %3 %4
where %1 is the function and %2-4 are the parameters of that function
Then, when your main script calls the library script, you just use
call library.bat function param1 param2 param3
Nice thank you very much. I have just started to learn cmd and was losing hope. This certainly gave me new energy. Can I pass unlimited number of parameters to call?
Offline
You can only refer to %1 through %9 at any given time, but when you use the shift command, you can pass in significantly more (I'm having trouble finding the exact number, but it seems to be over 100).
Offline
Just use:
call :%*
Offline
Just use:
call :%*
I use GOTO %1 in the header of my function library. Whith this I don't have to write call <all the parametrs> in the header.
Offline
If you do that, your arguments will be off by one.
Also, call returns to the line it was called from when it finishes, while goto does not.
Offline