You need two nested loops, the outer one goes through all the address lines and the inner one calculates the maximum font size possible for the current line to fit the address box width.
The lowest font size value of all lines is taken to be the final font size for the whole address.
The following code is doing that, please test and adjust where needed.
Just note it gets the appropriate font size by decreasing in steps of 0.5, you may decrease by lower value if useful.
define(&sText, string, '')
define(&fSize, measure, 12)
define(&minFontsize, integer, 9)
define(&fSizeMax, measure, 12)
define(&i, integer, 1)
define(&addressBoxWidth, measure, 2.0)
%first calculate the maximum font size allowed
For(&i, 2, 1, 5)
&sText := @(&i,1,100)
&fsize := 12
repeat
setstyleext(&Style1, &fSize, 0, [100], 100)
&fsize := &fsize - 0.5
until(or((stringwidth(&sText) <= &addressBoxWidth), (&fsize < 9.0)))
&fsize := &fsize + 0.5
if(&fsize < &fSizeMax)
&fSizeMax := &fsize
endif
EndFor()
%now print the address with maximum font size calculated above
setstyleext(&Style1, &fSizeMax, 0, [100], 100)
For(&i, 2, 1, 5)
&sText := @(&i,1,100)
show(&sText)
crlf()
endfor