1

I have a .bat file which does some stuff with the variables inside it. I have noticed a strange problem.

At the bottom of that file I have that line:

START _mz3_creator.bat %book_name%,%pg_count%,%pg_width%,%pg_height%,%pg_format%,%scale%,%jpg_q_l%,%jpg_q_h%,%res_px_l%,%res_px_h%,%book_type%,%zoomminscale%,%zoommaxscale%,%zoomsnap%,%zoomsteps%,%zoominit%,%maxloaded%,%pagethickness%,%maxthickness%,%thumbscale%,%logo_pos%,%settings%,%plugin_list%,%qualitycontrol%,%centercovers%,%cornerhint%,%pageoffset%,%dragrange%,%searchmethod%,%shadows%,%searchclear%,%startpage%,%version_name%,%make_pg%,%parameter_list%,%thumbloadtext%,%custom_webaddress%,%bookmark_title%,%make_what%,%logo_width%,%logo_height%,%page_type%,%side_bar%,%lang_list%,%hi_res_type%,%language%,%gallery_active%, %bookmark_type%,%thumbloadtextsize%,%elementsfadein%,%thumbs_fetch%, %bgcolor% 

(I pass 52 arguments for that file)

For now everything works, that _mz3_creator.bat file executes fine and it does its job.

But, I was wondering what values have these variables, so I used

ECHO START _mz3_creator.bat %book_name%, .......... etc 

and here's the problem - after I used the ECHO command I copied the output:

START _mz3_creator.bat "quick",14,816,1056,US,ž,40,90,36,96,pdf,0.25,4.0,"0.25,0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 4.0",2,0,32,0.2,40,0.25,"pw-w,ph-h-60","true, false, false, false, false","options,zoom",true,true,false,0,30,client,0.3,false,1,"pdf",y,"ž","please wait","http://stackoverflow.com",n,m,165,45,b,n,"ž",jpg,en,0,"u",12,false,0,"ž" 

and pasted it to a blank .bat file, and after execution I see some errors.

Why ?

I suppose there is something wrong with the variables formatting after I've copied them. Any ideas ?

EDIT

inside my original .bat file I see that line

SET scale=0 ... SET scale="%scale%" SET scale=%scale:"=% IF §%scale%==§ SET scale=§ IF %scale%==0 SET scale=§ 

and then in the output I see ž instead of §. I think it is treated as NULL value

3
  • OK, but in the original file they are separated by commas and it's working Commented Jun 24, 2012 at 18:01
  • 1
    @Joey - space, tab, comma, semicolon, equal: the CMD parser doesn't care. They all work as parameter delimiters. Commented Jun 24, 2012 at 19:54
  • dbenham, ok. You dissected that way more than I did :) Commented Jun 24, 2012 at 19:56

1 Answer 1

2

Excuse me. I think I don't understand what your problem is (specially when you said "For now everything works, that _mz3_creator.bat file executes fine and it does its job".

Independently of that, I think there are a couple points you should pay attention:

  • The parameters of a Batch file are used to execute the file with different unknown values, or with values that needs to be separated from those of the original calling file. I suppose that _mz3_creator.bat have a hard job to extract those 52 parameters (perhaps in a complex loop with shift commands?). You must be aware that when _mz3_creator.bat starts, it have access to the same 52 variables and values of the calling program, so all this job is entirely unnecessary (at least, from my point of view).

  • Start command is used when a separate execution thread is needed. I don't know if this is the case; otherwise the start command is unnecessary (a call command would be enough).

  • If you want to avoid that _mz3_creator.bat modify variable values that must remain the same in the calling program, just insert a setlocal command at beginning.

I hope it helps.

Antonio

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.