[net.micro] null as variable in batch file

2212msr@whuts.UUCP (ROBIN) (02/11/86)

Does anyone know how to detect a null as variable input in a batch file?
Specifically:

foo %1   --how do I detect case where %1 is omitted, thus avoiding
	   an error?  I've tried: 
                       if %1==''
                       if %1==' '
                       if %1==<CTRL @>
           all to no avail.  Any help or pointers would be appreciated.

Max S. Robin
AT&T Bell Laboratories
201-386-6865
email:whuxg!2212msr

lotto@talcott.UUCP (Jerry Lotto) (02/11/86)

In article <534@whuts.UUCP>, 2212msr@whuts.UUCP (ROBIN) writes:
> Does anyone know how to detect a null as variable input in a batch file?

	The simplest solution is:

	if %1.==. goto null
... process
	:null
	echo No input on command line
-- 

Gerald Lotto - Harvard Chemistry Dept.

 UUCP:  {seismo,harpo,ihnp4,linus,allegra,ut-sally}!harvard!lhasa!lotto
 ARPA:  lotto@harvard.EDU
 CSNET: lotto%harvard@csnet-relay

lotto@talcott.UUCP (Jerry Lotto) (02/11/86)

In article <534@whuts.UUCP>, 2212msr@whuts.UUCP (ROBIN) writes:
> Does anyone know how to detect a null as variable input in a batch file?
                                   ****
> Specifically:
> 
> foo %1   --how do I detect case where %1 is omitted, thus avoiding
                                              ********

	What do you really want to do here?  If you want to detect
no args, see the previous posting.  If you want to pass a null (ascii 0)
on a command line past the command processor, forget it.  The command
line parser will not respect your wishes.
-- 

Gerald Lotto - Harvard Chemistry Dept.

 UUCP:  {seismo,harpo,ihnp4,linus,allegra,ut-sally}!harvard!lhasa!lotto
 ARPA:  lotto@harvard.EDU
 CSNET: lotto%harvard@csnet-relay

tang@Shasta.ARPA (02/12/86)

> foo %1   --how do I detect case where %1 is omitted, thus avoiding
> 	   an error?  I've tried: 
>                        if %1==''
>                        if %1==' '
>                        if %1==<CTRL @>
>            all to no avail.  Any help or pointers would be appreciated.

Try this, I guess it will work :-)

	if $%1$ == $$

-----------------------------------

-mkt

story@calma.UUCP (Glen Story) (02/12/86)

In article <533@whuts.UUCP> 2212msr@whuts.UUCP (ROBIN) writes:
>Does anyone know how to detect a null as variable input in a batch file?
>Specifically:
>
>foo %1   --how do I detect case where %1 is omitted, thus avoiding
>	   an error?  I've tried 'if %1=='':goto xx' as well as
>==' '

The following will solve your problem:

		if x%1 == x goto ...

kim@mips.UUCP (Kim DeVaughn) (02/12/86)

[ ... go ahead, eat my bits ... ]

> Does anyone know how to detect a null as variable input in a batch file?
> Specifically:
> 
> foo %1   --how do I detect case where %1 is omitted, thus avoiding
> 	   an error?  I've tried 'if %1=='':goto xx' as well as
> ==' '

Hmmm ... I should probably try this out first, but my MS-DOS machine is
unavailable right now.  I *think* this will do what you want:

                   if .%1 == . goto xx

Note the "dots".  Also, I pretty sure that this will work too:

		   if "%1" == "" goto xx

/kim

-- 

UUCP:  {decvax,ucbvax,ihnp4}!decwrl!mips!kim
DDD:   415-960-1200
USPS:  MIPS Computer Systems Inc,  1330 Charleston Rd,  Mt View, CA 94043

pwong@pixel.DEC (Paul H. Wong, DPS/Graphics, 264-7918) (02/12/86)

<Max S. Robin writes:>
>foo %1   --how do I detect case where %1 is omitted, thus avoiding
>	   an error?  I've tried: 
>                       if %1==''
>                       if %1==' '
>                       if %1==<CTRL @>
>           all to no avail.  Any help or pointers would be appreciated.

	This seems to work for me:

		if Z%1==Z

	- Paul

---------------------------------------------------------------------
Paul H. Wong
Digital Equipment Corp.
Merrimack, NH
(603)-884-7918

ARPA: 	PWong%PIXEL.DEC@decwrl.arpa
USENET:	{allegra|decvax|ihnp4|ucbvax}!decwrl!dec-rhea!dec-pixel!pwong

boykin@datagen.UUCP (02/15/86)

<Max S. Robin writes:>
>foo %1   --how do I detect case where %1 is omitted, thus avoiding
>	   an error?  I've tried: 
>                       if %1==''
>                       if %1==' '
>                       if %1==<CTRL @>
>           all to no avail.  Any help or pointers would be appreciated.

I use the following to test for a null (non-existent) argument:

	IF '%1' == ''

Joe Boykin
Sr. Project Leader
Data General Corp.
{allegra, ihnp4, decvax}!datagen!boykin

ogasawar@noscvax.UUCP (Todd H. Ogasawara) (02/21/86)

In article <22@datagen.UUCP> boykin@datagen.UUCP writes:
><Max S. Robin writes:>
>>foo %1   --how do I detect case where %1 is omitted, thus avoiding
>>	   an error?  I've tried: 

This works pretty good for me:

	IF %0%1==%0 GOTO ...

%0 always equals itself if there is no arg following the invocation of
the batch command name itself.

Todd Ogasawara, Computer Sciences Corp.
NOSC-Hawaii Laboratories

UUCPmail: {akgua,allegra,decvax,ihnp4,ucbvax}!sdcsvax!noscvax!ogasawar
MILNET:   OGASAWAR@NOSC