JADE Environment Development Ideas

What's new in the upcoming JADE release?

IMPROVED DEVELOPER EFFICIENCY. ENHANCED SECURITY. SMOOTHER INTEGRATION

The JADE 2022 release meets tomorrow’s business demands.


Start your update to JADE's latest release

includesText() method on String primitive

We have many cases where we need to check if some text is included in a String. We would use:

if name.pos("smith",1) > 0 then
endif;

It would be nice if there was an includesText() method on String so this could change to:

if name.includesText("smith") then
endif;

We have created our own method that does this but this is an extra method call so it would be nice if there was a Jade method instead.
  • Guest
  • May 1 2019
  • Needs review
HistoricalComments
Brian Johnstone 24/05/2018 5:41:40 PM
@James - you can create your own 'multiple parameter' methods by using the 'ParamListType' pseudo type. For example, the following code would implement an 'includesOneOf' method which takes one or more parameters to match against - once again the formatting will get corrupted in this comment: ************************************************************************** includesOneOf( pStrings : ParamListType ) : Boolean ;

vars
paramListCount : Integer ;
paramIndex : Integer ;
nextEntry : Any ;

begin
paramListCount := app.getParamListTypeLength( pStrings );

foreach paramIndex in 1 to paramListCount do
nextEntry := app.getParamListTypeEntry( paramIndex, pStrings );
if not nextEntry.isKindOf( String ) then
// For real 'production ready code' it should probably raise an "invalid parameter type" exception
continue ;
endif;
if self.pos( nextEntry.String, 1 ) > 0 then
return true ;
endif;
endforeach;

return false ;
end;
**************************************************************************

Brian Johnstone 24/05/2018 5:32:57 PM
@Sam - unless this code is being called thousands/millions of times, I'd take the improved readability over the additional method call every time. ie: Method calls aren't that expensive most of the time, and people should avoid the urge for doing premature optimisation until they actually have a performance issue.

James Burnby 24/05/2018 9:23:20 AM
I would see great benefit here if it took multiple parameters, similar to isOneOf. e.g. if status.includesOneOf?("UAT,"Test").
  • Attach files
  • +4