Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to determine tabs needed for caption formating?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
How to determine tabs needed for caption formating?
Divers
Thread ID:
00903326
Message ID:
00903326
Vues:
46
Hi All,

I have a function that creates letter caption dynamically as follows:
I have table1 whose structure is:
format_id		label_name	value_ref
1			Claim Number	bbb.field1
1			Insured		bbb.field2
1			Claimant	bbb.field3
The size of label_name field is character 30. The second field stores expressions to be evaluated at the time of caption generation.

The desired result should be as follows using monospaced font, such as Courier New:
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 && GetCaptions
I 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,

Any help or suggestion will be appreciated greatly.

Dawa


//Update to the message

I have posted the message above earlier.
I've modified the code:
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 && GetCaptions
So I do get the desired format.

However if somebody, has a way of getting the exact number tabs, I would still appreciate the solution.

Dawa
Dawa Tsering


"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

Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform