Loading ...
Sorry, an error occurred while loading the content.

17672Re: Newbie seeks help with array processing

Expand Messages
  • dracorat
    Mar 28, 2008
      Here is a program I wrote that takes apart a string and then creates
      an XML document based on the results.

      I hope it has the info you need. If not, ask for more.

      The source data looks like this btw:
      36094 PERSON NAME 3515 PENNYROYAL LN 80906 $93,147.86 Withdrawn
      36630 ANOTHER NAME 1103 N CHELTON RD 80909 $93,460.75 Withdrawn
      37654 AND YET ANOTHER 537 HOLLY DR 80911 $88,991.70 Redeemed by Owner

      Now, the clip:
      ^!SET %DocIndex%=^$GetDocIndex$
      ^!SET %FileCheck%=^$GetFiles("c:\";Transactional.XML)$
      ^!SetWordWrap OFF
      ^!If "^%FileCheck%" > "" NEXT ELSE CreateFile
      ^!Open "C:\Transactional.XML" /J=-1
      ^!SetWordWrap OFF
      ^!Goto BeginWork
      :CreateFile
      ^!TOOLBAR New Document
      ^!SetWordWrap OFF
      ^!Save AS "C:\Transactional.XML"

      :BeginWork
      ^!SetDocIndex ^%DocIndex%
      ^!Jump DOC_START
      ^!Set %TotalLines%=^$GetLineCount$
      ^!Set %CurrentLine%=0

      :WorkLoop
      ^!Select LINE
      ^!Find
      "\w*(\d+)\s(\D+)((?:.(?!80\d{3}))+.)(80\d{3})[\w\s\d\.\,\-\'\#]*(\$[\d\.\,]+)\s*(\w*)"
      HRS
      ^!SetArray %Data%=^$GetReSubStrings$
      ^!IF ^%Data0% < 6 BADROW
      ^!SET %Data1%=^$StrReplace("&";"&";^%Data1%;False;False)$
      ^!SET %Data2%=^$StrReplace("&";"&";^%Data2%;False;False)$
      ^!SET %Data3%=^$StrReplace("&";"&";^%Data3%;False;False)$
      ^!SET %Data4%=^$StrReplace("&";"&";^%Data4%;False;False)$
      ^!SET %Data5%=^$StrReplace("&";"&";^%Data5%;False;False)$
      ^!SET %Data6%=^$StrReplace("&";"&";^%Data6%;False;False)$
      ^!Open "C:\Transactional.XML" /J=-1
      ^!InsertText
      "<Transaction><SiteID>^%Data1%</SiteID><Name>^%Data2%</Name><Address>^%Data3%</Address><ZIP>^%Data4</ZIP><Valuation>^%Data5%</Valuation><Status>^%Data6%</Status></Transaction>^P"
      ^!Save AS "C:\Transactional.XML"
      ^!Goto PostProcessing

      :BadRow
      ^!Prompt "The Highlighted Row Could Not Be Processed"

      :PostProcessing
      ^!SetDocIndex ^%DocIndex%
      ^!Set %CurrentLine%="^$Calc(^%CurrentLine%+1)$"
      ^!If ^%CurrentLine%=^%TotalLines% FinishOut
      ^!Select 0
      ^!Jump +1
      ^!Goto WorkLoop

      :FinishOut
      ^!Select 0
      ^!Jump DOC_END
      ^!Open "C:\Transactional.XML" /J=-1



      Inside the WorkLoop has most of what you're asking for I believe but
      the whole program is included so you can test with it.

      Enjoy.

      --Keith


      --- In ntb-clips@yahoogroups.com, Ed Wilson <eddwilson@...> wrote:
      >
      > Can anyone point me to resources/advice on use of arrays in NoteTab?
      And then string concatenation? Ed
      >
    • Show all 9 messages in this topic