Written by

Applications Development Consultant at The Ohio State University, Wexner Medical Center
Question Jonathan Anglin · Jun 18, 2020

Get count of substrings within a string

I have a code tag that performs some logic in a DTL, and want to add to it the ability to find the number of substrings delimited by a dollar sign ($) within a particular string. I have tried the following which compiles just fine, but generates an error when testing in the Data Transformation Builder.

set lineCount = $DCOUNT(reportBody,"$")

ERROR <Ens>ErrException: <SUBSCRIPT>zTransform+985^LH.IAMON.IAMONORU1XsformDTC2.1 *DCOUNT() Encoded subscript 1 > 511 bytes -- logged as '-' number - @' set lineCount = DCOUNT(reportBody,"$")'

Comments

Robert Cemper · Jun 18, 2020
set lineCount = $Length(reportBody,"$")

should do the trick 

0
Jonathan Anglin  Jun 18, 2020 to Robert Cemper

Yes, I just found that at the bottom of the $PIECE document. Thank you, Robert!

0
Robert Cemper · Jun 18, 2020

DCOUNT is a function of MV Basic. Not of ObjectScript !

0