Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
101 VFP7 THings, Part 13 - AProcInfo()
Message
 
 
To
20/12/2000 00:14:00
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00455019
Message ID:
00455400
Views:
43
>>>C'mon Mike, that's something one could write over a weekend. What I'd prefer would be to have the parameters in AProcInfo() as well, but then if you really need some code replication beast of this kind, it's feasible by simply writing a little parser/generator of the kind.
>>>
>>>As usual (how many times have I written this disclaimer?), this doesn't mean I volunteered :).
>>
>>No, no, you're caught :) In Russian: "If you say A, you should say B" :)
>>Give us this parser tomorrow :)
>
>I wish no boss should ever see me working at this speed :). Check the Galley joke on my website... just for reference.
>
>Here it is, quick'n'dirty, probably needs some tweaking (like replacing the 'of [prgfile.prg]' clause in Define Class with the current source file, if it's there). This is al feasible in VFP6, I just couldn't stand the itch and did it in VFP7, frankly to show how you can't write a parser without either using FoxTools functions Words() and Wordnum (aka GetWordCount() and GetWordNum() in 7), or joining Ed Rauh's church.
>
>
>* parameter checking left to users (if any)
>LPARAMETERS tcPrgfile, tcNewFile, tcPrefix
>CLOSE DATABASES all
>CREATE CURSOR newprg (cLine c(127))
>CREATE CURSOR prg (cLine c(127))
>
>APPEND FROM (tcPrgFile) sdf
>SCAN
>	lcLine=LOWER(ALLTRIM(cLine))
>	lcFirstWord=GETWORDNUM(lcLine, 1)
>	do case
>		CASE INLIST(lcFirstWord, '#', 'lparam','param','enddef','endp','endfu','proc','func','protect','hidden')
>			INSERT into newprg (cLine) value (TRIM(prg.cline))
>		CASE lcFirstWord='define' and GETWORDNUM(lcLine,2)='class'
>			lcOldClass=GETWORDNUM(lcLine, 3)
>			lcOldParent=GETWORDNUM(SUBSTR(lcLine, AT('as ',lcline)+3),1)
>			lcNewClass=STUFF(lcOldClass,1, LEN(tcPrefix), tcPrefix)
>			lcNewLine=STRTRAN(lcLine, lcOldClass,lcNewClass)
>			lcNewLine=STRTRAN(lcNewLine, lcOldParent, lcOldClass)
>			lcComment="* redefinition of "+lcOldClass+" of "+tcPrgFile
>			INSERT into newprg(cLine) value (lcComment)
>			INSERT into newprg(cLine) value (lcNewLine)
>	ENDCASE
>ENDSCAN
>
>SELECT newprg
>SET TEXTMERGE on noshow to memvar cNewText
>SCAN
>	\\<<TRIM(cLine)>>
>	\
>ENDSCAN
>SET TEXTMERGE to
>SET TEXTMERGE off show
>=STRTOFILE(cNewText, tcNewFile)
>
>
>
>I know, the result would need some extra formatting... what else would you want in 20 minutes?

That was really quick :) I could not expect :) Now the questions:
1) What is tcPrefix?
2) Would Inlist work, if I don't stortcut the reserved words (e.g. I usually use the whole word, like: lparameters, define, createobject - this is just a habit) Does it depend on SET EXACT ? (In our environment we have set exact on).

I have to study code more for other questions, these are after first glance.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform