Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1


Eyeballing Memo laden dbf without specific screen - vcx/scx in particular 01 Aug 2021 21:59 #19223

  • mainhatten
  • mainhatten's Avatar
  • Topic Author

  • Posts: 199
  • This is ***not*** something X# specific, but something borne out of the memo-heavy vcx/scx tables used in vfp for GUI design, but can be used on any dbf.
    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.
    function VcxString(tcAliasOpt, tcFilterOpt, tcSkipFieldsOpt, tlJSONOpt, tlShowEmptyOpt, tlOnlyMemoOpt)
      local lcRet, lnSelect
      if empty(m.tcFilterOpt)
        tcFilterOpt = ".t."
      lnSelect = select()
      lcRet = ""
      if vartype(m.tcAliasOpt)=="C"
        select (m.tcAliasOpt)
      scan for &tcFilterOpt
        lcRet = m.lcRet + RecString(m.tcSkipFieldsOpt, m.tlJSONOpt, m.tlShowEmptyOpt, m.tlOnlyMemoOpt) + chr(10)
      select (m.lnSelect)
      return m.lcRet
    function RecString(tcSkipFieldsOpt, tlJSONOpt, tlShowEmptyOpt, tlOnlyMemoOpt)
      if vartype(m.tcSkipFieldsOpt)!="C"
        tcSkipFieldsOpt = "objcode"
        tcSkipFieldsOpt = ""
      *-- 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
              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
      return m.lcErg + iif(m.tlJSONOpt, "}" , "</Record>") + chr(10)

    hope it interests & helps some here. Was used to fix the erroring vcx in FoxRun, next version will have those crypto modules created by Ed again..


    Please Log in or Create an account to join the conversation.

    Last edit: by mainhatten.
    • Page:
    • 1