/*REXX program determines the LCSUBSTR (Longest Common Substring) via a function. */ parse arg a b . /*obtain optional arguments from the CL*/ if a=='' then a= "thisisatest" /*Not specified? Then use the default.*/ if b=='' then b= "testing123testing" /* " " " " " " */ say ' string A =' a /*echo string A to the terminal screen.*/ say ' string B =' b /* " " B " " " " */ say ' LCsubstr =' LCsubstr(a, b) /*display the Longest Common Substring.*/ exit 0 /*stick a fork in it, we're all done. */ /*──────────────────────────────────────────────────────────────────────────────────────*/ LCsubstr: procedure; parse arg x,y,,$; #= 0 /*LCsubstr: Longest Common Substring. */ L= length(x); w= length(y) /*placeholders for string length of X,Y*/ if w# then do; $= _; #= k; end end /*k*/ /* [↑] determine if string _ is longer*/ end /*j*/ /*#: the current length of $ string.*/ return $ /*$: (null if there isn't common str.)*/