Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to display parameters passed?
Message
From
09/05/2005 16:26:18
 
 
To
09/05/2005 16:01:01
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01012215
Message ID:
01012277
Views:
37
>>I can not see the use, but you can use something like:
>>
>>Warning!!! Very ugly code following! I am not responsible for any brain damage it can cause, look at it under your own risk :)
>>
>>
>>* Add this code inmediately after the (l)parameters command
>>set safety off
>>list memory to file c:\memory.txt noconsole
>>
>>local laMemory(1), lnPCount, lnLines, lnLine, lcName, lnPar, lcScope, laDef(1), lnDef, lnDefs
>>
>>set library to foxtools
>>lnPar		= 0
>>lnPCount	= Pcount()
>>lnLines		= Alines(laMemory, Filetostr('c:\memory.txt'),1+8,Chr(13)+Chr(10))
>>for lnLine = 1 to lnLines
>>	lcMemory	= reduce(Chrtran(laMemory[lnLine], Chr(9), ' '))
>>	lnDefs		= Alines(laDef, lcMemory,1+8, ' ')
>>	if lnDefs >= 5
>>		lcName		= 'm.' + Alltrim(laDef[1])
>>		lcScope		= Upper(laDef[2])
>>		if Inlist(lcScope, 'PRIV', 'LOCAL') and Upper(laDef[lnDefs]) = Program()
>>			lnPar		= lnPar + 1
>>			if lnPar <= lnPCount
>>				? lcName, Evaluate(lcName)
>>			else
>>				exit
>>			endif
>>		endif
>>	endif
>>endfor
>>
>>
>
>
>With a bit more structure...
>
>* Add this code inmediately after the (l)parameters command
>set safety off
>list memory to file c:\memory.txt noconsole
>
>local lcMemory, lnLine, lcLines, lcName, lnPar, pnPCount
>
>
>lnPar		= 0
>lnPCount	= Pcount()
>lnLines		= Alines(laMemory, Filetostr('c:\memory.txt'),.T.,Chr(13)+Chr(10))
>for lnLine = 1 to lnLines
>
>	lcMemory	= Chrtran(laMemory[lnLine], Chr(9), ' ')
>	*-- replace dependency on Foxtools
>	DO WHILE '  '$lcMemory
>		lcMemory = STRTRAN(lcMemory,'  ',' ')
>	ENDDO
>	
>	DO case
>	CASE lnPar > lnPCount
>		EXIT
>	CASE NOT UPPER(RIGHT(lcMemory, LEN(PROGRAM())))==PROGRAM()
>	CASE NOT INLIST( UPPER(GETWORDNUM(lcMemory,2,' ')), "PRIV", "LOCAL")
>	OTHERWISE
>		lcName = 'm.' + GETWORDNUM(lcMemory,1,' ')
>		? lcName, EVALUATE(lcName)
>	ENDCASE
>NEXT
>
>
Now lets call it as a reusable function...
* save as:  ParamList
* call as:  DO ParamList with 1,2,3

LPARAMETERS first, second, third
pcnt = PCOUNT()
FOR i=1 TO pcnt
	lcName = aPara( i, pcnt)
	? lcName, EVALUATE(lcName)
NEXT 

RETURN

***************************************************

PROCEDURE aPara( nPara, pcnt )

set safety off
list memory to file c:\memory.txt noconsole

local lcMemory, lnLine, lcLines, lcName, lnPar, pnPCount

LOCAL aParam[16]
cProgram 	= PROGRAM(PROGRAM(-1)-1)
lnPar		= 0
lnPCount	= Pcount()
lnLines		= Alines(laMemory, Filetostr('c:\memory.txt'),.T.,Chr(13)+Chr(10))
for lnLine = 1 to lnLines

	lcMemory	= Chrtran(laMemory[lnLine], Chr(9), ' ')
	*-- replace dependency on Foxtools 
	DO WHILE '  '$lcMemory
		lcMemory = STRTRAN(lcMemory,'  ',' ')
	ENDDO
	
	DO case
	CASE lnPar > lnPCount
		EXIT 
	CASE NOT UPPER(RIGHT(lcMemory, LEN(cProgram)))==cProgram
	CASE NOT INLIST( UPPER(GETWORDNUM(lcMemory,2,' ')), "PRIV", "LOCAL")
	OTHERWISE
		lcName = 'm.' + GETWORDNUM(lcMemory,1,' ')
		lnPar = lnPar + 1 
		aParam[lnPar] = lcName
	ENDCASE 
NEXT 

RETURN aParam[ nPara ]
Greg Reichert
Previous
Reply
Map
View

Click here to load this message in the networking platform