Use of getopt with and without argument

Hi,

I am in middle of using some getopt command and am finding some issue. The usage of my script can be like this:
abc.sh <-d | -p |-r> [< -s single_id> | file>] -online < 0 | 1>
The first argument can be either -d or -p or -r. The second argument can be either -s and a id or a file name. So I am stuck up in writing getopts for this.
The below snipper doesn't work.

while getopts "d:p:r:s:o:" param
do

   case "$param" in      

      -d|-p|-r)    deviceType=$param      			
                  IN_FILE=$OPTARG
                  statFile $IN_FILE                
                ;;

      -s)        requested_id=$OPTARG ;;

In this case i am not sure whether the 2nd argument is -s or a file name. that means -d may or may not have an option. How can I write that. In this perhaps -d is always excepting a next argument and breaking.

Please help me.

Thanks in advance.
Sachin

If you want to give argument to a option we should give ':' after the argument . If you don't want argument for an option the ';' is not needed after the option .

while getopts "dprs:o" param
   Here option d,p,r,o is not deal with the arguments ,so here ';' is not needed .But ':' is need after the option s,because it deals with argument .

Thanks for the reply. But the problem is dpr argument may or may not have an option. For example:
-d filename --> with option
-d -s id --> without option.

I need to handle both type of arguments as I have shown above. Both are valid and i need to handle them.
So please suggest me some way.

Thanks
Sachin