Hi all,
Can someone explain me what the real difference is between *OMIT and *NOPASS?
Thx already in advance
Can someone explain me what the real difference is between *OMIT and *NOPASS?
Thx already in advance
d getDateStrUSA pr 10 varying
d date d const options( *nopass )
d zero n const options( *nopass )
d inc n const options( *nopass )
d sep 1 const options( *nopass )
/free
// Get Todays Date as a USA Formatted Date String
usaDateString = getDateStrUSA();
// Get This Date as a USA Formatted Date String
usaDateString = getDateStrUSA( dateField );
// Get This Date as a USA Formatted Date String,
// not zero-suppressed
usaDateString = getDateStrUSA( dateField : *off );
// Get This Date as a USA Formatted Date String,
// not zero-suppressed, with separators
usaDateString = getDateStrUSA( dateField : *off : *on );
// Get This Date as a USA Formatted Date String,
// not zero-suppressed, with separators, use "." as separator
usaDateString = getDateStrUSA( dateField : *off : *on : '.' );
/end-free
d getDateStrUSA pi 10 varying
d date d const options( *nopass )
d zero n const options( *nopass )
d inc n const options( *nopass )
d sep 1 const options( *nopass )
d dateIn s d
d zeroSuppress s n inz( *on )
d incSeps s n inz( *on )
d sepChar s 1 inz( '/' )
/free
select ;
when %parms() = 0 ;
dateIn = %date();
when %parms() = 1 ;
dateIn = date ;
when %parms() = 2 ;
dateIn = date ;
zeroSuppress = zero ;
when %parms() = 3 ;
dateIn = date ;
zeroSuppress = zero ;
incSeps = inc ;
when %parms() = 4 ;
dateIn = date ;
zeroSuppress = zero ;
incSeps = inc ;
sepChar = sep ;
endsl ;
/end-free
d getDateStrUSA pr 10 varying
d date d const options( *omit )
d zero n const options( *omit )
d inc n const options( *omit )
d sep 1 const options( *omit )
/free
// Get Todays Date as a USA Formatted Date String
usaDateString = getDateStrUSA( *omit : *omit : *omit : *omit );
// Get This Date as a USA Formatted Date String
usaDateString = getDateStrUSA( dateField : *omit : *omit : *omit );
// Get This Date as a USA Formatted Date String,
// not zero-suppressed
usaDateString = getDateStrUSA( dateField : *off : *omit : *omit );
// Get This Date as a USA Formatted Date String,
// not zero-suppressed, with separators
usaDateString = getDateStrUSA( dateField : *off : *on : *omit );
// Get This Date as a USA Formatted Date String,
// not zero-suppressed, with separators, use "." as separator
usaDateString = getDateStrUSA( dateField : *off : *on : '.' );
/end-free
d getDateStrUSA pi 10 varying
d date d const options( *omit )
d zero n const options( *omit )
d inc n const options( *omit )
d sep 1 const options( *omit )
d dateIn s d
d zeroSuppress s n inz( *on )
d incSeps s n inz( *on )
d sepChar s 1 inz( '/' )
/free
if %addr( date ) = *NULL ;
dateIn = %date();
else ;
dateIn = date ;
endif ;
if %addr( zero ) <> *NULL ;
zeroSuppress = zero ;
endif ;
if %addr( inc ) <> *NULL ;
incSeps = inc ;
endif ;
if %addr( sep ) <> *NULL ;
sepChar = sep ;
endif ;
/end-free
d getDateStrUSA pr 10 varying
d date d const options( *nopass : *omit )
d zero n const options( *nopass : *omit )
d inc n const options( *nopass : *omit )
d sep 1 const options( *nopass : *omit )
/free
// Get This Date as a USA Formatted Date String,
// zero-suppressed, with separators, use "." as separator
usaDateString = getDateStrUSA( *omit : *omit : *omit : '.' );
/end-free
Now the programmer doesn't have to research to remember that he should send %date(), *on, *on for the first three parameters. This could also allow the developer to change the default procedure behaviors without the programmer needing to change the calling code. I'll leave it to the reader to determine the pros and cons of that approach.
Using both options also increases the work you must do in order to handle those incoming parameters. If sent, the *omit placeholder counts as a parameter, just one whose value is null. So basically you have to check for whether a parm was sent and whether it has a value of null:
d getDateStrUSA pi 10 varying
d date d const options( *nopass : *omit )
d zero n const options( *nopass : *omit )
d inc n const options( *nopass : *omit )
d sep 1 const options( *nopass : *omit )
d dateIn s d
d zeroSuppress s n inz( *on )
d incSeps s n inz( *on )
d sepChar s 1 inz( '/' )
/free
if %parms() = 0 ;
dateIn = %date();
endif ;
if %parms() > 0 ;
if %addr( date ) = *NULL ;
dateIn = %date();
else ;
dateIn = date ;
endif ;
endif ;
if %parms()> 1 ;
if %addr( zero ) <> *NULL ;
zeroSuppress = zero ;
endif ;
if %parms()> 2 ;
if %addr( inc ) <> *NULL ;
incSeps = inc ;
endif ;
endif ;
if %parms()> 3 ;
if %addr( sep ) <> *NULL ;
sepChar = sep ;
endif ;
endif ;
/end-free
/free // Compiler allows this myfield = getSomething(parm1 : *omit : parm3); // Compiler doesn't allow this myfield = getSomething(parm1 : : parm3); /end-free
Comment