Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: dashes in batch file  (Read 3181 times)

0 Members and 1 Guest are viewing this topic.

infogirl

    Topic Starter


    Greenhorn

  • Experience: Beginner
  • OS: Unknown
dashes in batch file
« on: February 16, 2011, 12:52:20 PM »
Hello, can anyone explain me what these dashes means and do in this line from batch file?

if -%1 == - GOTO error1
:error1
echo please write file name

When I write only batch file name in prompt line (Windows Vista) without any other file and run it, I get the message 'please write file name'.
I would like to know how these dashes work and where can I use it.

Salmon Trout

  • Guest
Re: dashes in batch file
« Reply #1 on: February 16, 2011, 02:18:47 PM »
The dash is so you can test for a blank parameter. You could use any character. Often people use quotes before and after, or whatever.

if [%1==[ echo parameter is blank
if "%1"=="" echo parameter is blank
if $%1$==$$ echo paramter is blank
if cat%1==cat echo parameter is blank




infogirl

    Topic Starter


    Greenhorn

  • Experience: Beginner
  • OS: Unknown
Re: dashes in batch file
« Reply #2 on: February 17, 2011, 04:02:24 AM »
Thank you for timeliness. Really helped me :)))