Page 1 of 1

About call Function with Arguments

Posted: 28 Nov 2018 16:03
by goodywp
I just had a test about call function with arguments

Code: Select all

@echo off
echo.going to execute myDosFunc with different arguments

set fdl_1=function1
set fdl_2=function2
set fdl_3=function3

call:myDosFunc %fdl_1% *xt1.txt
call:myDosFunc %fdl_2% *xt2.txt
call:myDosFunc %fdl_3% *xt3.txt

goto:eof


::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------

:myDosFunc    - here starts my function identified by it's label
cd C:\Users\test
if exist %~1 (
	cd %~1
	copy %~2 C:\Users\test\function\
	)

goto:eof
This above code works well and I got 3 .txt files copied to subfolder function

Now I use the similar code to do this following job and failed to do so, can not figure out why?

Code: Select all


set NAR_COMP_6=NAR KIA Tetra 0521
set NAR_COMP_7=NAR Applications
set NAR_COMP_8=NAR TSA Tetra 0521


call:convertFunc %NAR_COMP_6% *KIA.P3A
call:convertFunc %NAR_COMP_7% *852046.P3A
call:convertFunc %NAR_COMP_8% *TSA.P3A

goto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------


:convertFunc    - here starts Convert function 
cd "%NEW_PACKAGE_BASE_PATH%\%NEW_PACKAGE_NAME%\%NEW_PKG_PART_NO%\Factory Download\TETRA\TELIUM3"

if exist %~1 (
	cd %~1
	copy %~2 C:\auto_mockup_pkg\Tools\PACKAGER\
	)

goto:eof
Now the above code is not working... only thing different is

cd "%NEW_PACKAGE_BASE_PATH%\%NEW_PACKAGE_NAME%\%NEW_PKG_PART_NO%\Factory Download\TETRA\TELIUM3"

But I had variable input for all the %NEW_PACKAGE_BASE_PATH%\%NEW_PACKAGE_NAME%\%NEW_PKG_PART_NO%\Factory Download\TETRA\TELIUM3
After run, prompt to %NEW_PACKAGE_BASE_PATH%\%NEW_PACKAGE_NAME%\%NEW_PKG_PART_NO%\Factory Download\TETRA\TELIUM3 that mean cd is working correctly
But nothing happened...
when I comment out if exist %~1 (
it complain
The system cannot find the path specified. (for cd %~1)
The system cannot find the file specified.. (for copy %~2 C:\auto_mockup_pkg\Tools\PACKAGER\)

Physically checked the folders are there and files too, Any reason why I can not do it ...
Thanks

Re: About call Function with Arguments

Posted: 28 Nov 2018 16:30
by Squashman
When file and folder names have spaces in them, what are you supposed to do?

Re: About call Function with Arguments

Posted: 29 Nov 2018 04:49
by goodywp
Squashman wrote:
28 Nov 2018 16:30
When file and folder names have spaces in them, what are you supposed to do?
OOPS again the space forgot to take care of.. My bad..
Should I delete this post, please advise...
Thanks

Re: About call Function with Arguments

Posted: 30 Nov 2018 10:42
by Ed Dyreen
goodywp wrote:
29 Nov 2018 04:49
OOPS again the space forgot to take care of.. My bad..
Should I delete this post, please advise...
Thanks
Yes, I would appreciate that :mrgreen: