It was borne last century when creating vfp classes from Rational Rose models and I needed to eyeball a record in toto, including the memo fields.
First it read out each record only to XML, with some parameters to supress empty fields or if wanted show only Memo (rest in Browse).as well as filtering the records processed.
Nowadays the HackVCX tools and Thor support exist - also tools in source to move from and to XML or JSON or create GIT-easy text from vfp vcx,scx,frx files and THOSE ARE PRODUCTION READY.
This is not -but it is tiny 2 screenful of code for eyeballing based on "table handling" used by vfp and xBase afficcionados. The JSON option added later has 2 kinks: it does NOT escape the handful of chars needing escaping if going after specs and Char/String/Memo values are wrapped in BACKTICKS to show string delimiters used in vfp as well as "formated code". If that departure bugs you - you have the source....
Me doing QnD stuff..And certainly not overdoing that commenting habit, I know.
Code: Select all
function VcxString(tcAliasOpt, tcFilterOpt, tcSkipFieldsOpt, tlJSONOpt, tlShowEmptyOpt, tlOnlyMemoOpt)
local lcRet, lnSelect
if empty(m.tcFilterOpt)
tcFilterOpt = ".t."
endif
lnSelect = select()
lcRet = ""
if vartype(m.tcAliasOpt)=="C"
select (m.tcAliasOpt)
endif
scan for &tcFilterOpt
lcRet = m.lcRet + RecString(m.tcSkipFieldsOpt, m.tlJSONOpt, m.tlShowEmptyOpt, m.tlOnlyMemoOpt) + chr(10)
endscan
select (m.lnSelect)
return m.lcRet
function RecString(tcSkipFieldsOpt, tlJSONOpt, tlShowEmptyOpt, tlOnlyMemoOpt)
if vartype(m.tcSkipFieldsOpt)!="C"
tcSkipFieldsOpt = "objcode"
tcSkipFieldsOpt = ""
endif
*-- supress finding partial keys in CSV
tcSkipFieldsOpt = iif(at(m.tcSkipFieldsOpt, ",")=1, "", ",") + lower(m.tcSkipFieldsOpt) ;
+ iif(rat(m.tcSkipFieldsOpt, ",")=1, "", ",")
local laFields[1], lcErg, lcFName, lcFValue, lcTixValue, lnFields, lnRun
lnFields = afields(laFields)
lcErg = iif(m.tlJSONOpt, "{" , "<Record>") + chr(10)
for lnRun = 1 to m.lnFields
if !m.tlOnlyMemoOpt or laFields[m.lnRun,2]=="M"
lcFName = proper(laFields[m.lnRun,1])
lcFValue = transform(evaluate(m.lcFName))
do case
case !m.tlShowEmptyOpt and empty(m.lcFValue)
case ","+lower(m.lcFName)+"," $ m.tcSkipFieldsOpt
otherwise
lcTixValue = iif(m.tlJSONOpt and type(m.lcFName) $ "CM", '`', '')
* this is only eyeballtool in JSON !
* wrapping value strings in backticks and NOT escaping according to specs!
lcErg = m.lcErg ;
+ iif(m.tlJSONOpt, '"', '<') + m.lcFName + + iif(m.tlJSONOpt, '" : ', '>');
+ m.lcTixValue + m.lcFValue ;
+ iif(m.tlJSONOpt, m.lcTixValue, '</' + m.lcFName + '>') + chr(10)
* manual filter option
*if "phx"$lower(m.lcFValue)
* wait window m.lcFName +chr(13) + m.lcFValue
*endif
endcase
endif
next
return m.lcErg + iif(m.tlJSONOpt, "}" , "</Record>") + chr(10)
thomas