Ignore:
Timestamp:
2006-08-24T16:19:13+12:00 (18 years ago)
Author:
kjdon
Message:

changed parse2::parse so that it returns -1 on error, 0 on success, or if allow_extra_options is specified, then on success returns the number of args left over.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/parse2.pm

    r11650 r12546  
    185185# Parameters: 1.(Array pointer of the user given argument)
    186186#             2.(Array pointer of plugin pre-defined argument list) 
    187 #             3.(Self pointer, where we store all the argument value)
     187#             3.(Hash pointer, where we store all the argument value)
    188188# Pre-condition: Plugin gives the parameters to parse function in parse2
    189 # Post-condition: Store all the default or user given values to the $self->{$ArgumentName}.
    190 #                 Since $self is a pointer from plugin, plugin will have every values we set.
    191 # Return value: 1 is parsing successful, 0 is failed.
     189# Post-condition: Store all the default or user given values to the hash->{$ArgumentName}.
     190#                 Since hash may be a plugin $self, plugin will have every values we set.
     191#             4. Optional "allow_extra_options" argument. If this is set, then
     192#                its ok to have arguments that are not in the predefined list
     193# Return value: -1 if parsing is unsuccessful
     194#                other value for success. This will be 0 unless "allow_extra_options" is set, in which case it will be the number of extra arguments found.
    192195#-----------------------------------------
    193196sub parse
     
    239242        if(processArg($hashArg{$strOneArg},$aryptUserArguList,\%hashInputArg) == 0){
    240243            print STDERR "<BadArgumentValue a=$strOneArg>\n";
    241             return 0;}
     244            return -1;}
    242245        }
    243246       
     
    254257            print STDERR "<BadArgument a=$strOneArg>\n";
    255258            print STDERR " Error: occur in parse2.pm::parse()\n Extra Arguments: $strOneArg\n";
    256             return 0;
     259            return -1;
    257260        }
    258261        }
     
    271274        {
    272275        print STDERR " Error: occur in parse2.pm::parse()\n Invalid Argument: $strOneArg\n";
    273         return 0;
     276        return -1;
    274277        }
    275278    }
     
    294297        if(defined $hashOneArg->{"range"})
    295298        {
    296         if(checkRange($hashOneArg->{"range"},$hashInputArg{$strArgName},$strArgName) == 0){ return 0;}
     299        if(checkRange($hashOneArg->{"range"},$hashInputArg{$strArgName},$strArgName) == 0){ return -1;}
    297300        }
    298301        if(defined $hashOneArg->{"char_length"})
    299302        {
    300         if(checkCharLength($hashOneArg->{"char_length"},$hashInputArg{$strArgName},$strArgName) == 0){ return 0;}
     303        if(checkCharLength($hashOneArg->{"char_length"},$hashInputArg{$strArgName},$strArgName) == 0){ return -1;}
    301304        }
    302305        $self->{"$strArgName"} = $hashInputArg{"$strArgName"};
     
    334337    else
    335338    {
    336     return 1;
     339    return 0;
    337340    }
    338341}
Note: See TracChangeset for help on using the changeset viewer.