format_id label_name value_ref 1 Claim Number bbb.field1 1 Insured bbb.field2 1 Claimant bbb.field3The size of label_name field is character 30. The second field stores expressions to be evaluated at the time of caption generation.
Claim Number : 424546
Insured : John Doe
Claimant : Jane Doe
My function is as follows:FUNCTION GetCaptions LPARAMETERS lpnFormat,lpnFileNumber LOCAL ARRAY laCaptions(1,2) SELECT * ; FROM mydb!table2 ; WHERE table1.filenum=m.lpnFileNumber ; INTO CURSOR bbb m.lcReturn = [] IF _tally > 0 ; THEN SELECT label_name,value_ref ; FROM mydb!table1 ; WHERE table1.format_id=m.lpnFormat ; INTO ARRAY laCaptions FOR i = 1 TO _tally m.lcReturn = m.lcReturn + ; ALLTRIM(m.laCaptions(i,1)) + ; REPLICATE(CHR(9),how many tabs)+[: ]+ ; TRANSFORM(EVALUATE(m.laCaptions(i,2)))+CHR(13) NEXT USE IN bbb ENDIF RETURN m.lcReturn ENDFUNC && GetCaptionsI would like an algrithm, to replace the NNN below, that will determine the number of tabs need to get the desired format.
REPLICATE(CHR(9),NNN)TIA,
REPLICATE(CHR(9),NNN)to
SPACE(30-LEN(m.laCaptions(i,1))So the code is as follows:
FUNCTION GetCaptions LPARAMETERS lpnFormat,lpnFileNumber LOCAL ARRAY laCaptions(1,2) SELECT * ; FROM mydb!table2 ; WHERE table1.filenum=m.lpnFileNumber ; INTO CURSOR bbb m.lcReturn = [] IF _tally > 0 ; THEN SELECT label_name,value_ref ; FROM mydb!table1 ; WHERE table1.format_id=m.lpnFormat ; INTO ARRAY laCaptions FOR i = 1 TO _tally m.lcReturn = m.lcReturn + ; ALLTRIM(m.laCaptions(i,1)) + ; SPACE(30-LEN(m.laCaptions(i,1))+[: ]+ ; TRANSFORM(EVALUATE(m.laCaptions(i,2)))+CHR(13) NEXT USE IN bbb ENDIF RETURN m.lcReturn ENDFUNC && GetCaptionsSo I do get the desired format.
"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."
- Ephesians 4:29-30 NIV
Dare to Question -- Care to Answer
Time is like water in a sponge, as long as you are willing you can always squeeze some.
--Lu Xun, Father of Modern Chinese Literature