[Gambas-user] help with some simple parsing

Stephen Bungay sbungay at ...981...
Wed May 6 16:52:25 CEST 2009


   Hi Richard

    This code snippet will dump the text into a TextArea for you, it 
asumes (a bad thing) that there are no newline characters in the data 
and as such works with your sample. I used a button to launch the 
code... the important bits are in the middle... :)

PUBLIC SUB ButtonGO_Click()
   DIM hFile AS File
   DIM LineInput AS String
   DIM ScrapString AS String
   DIM SPlitString AS String[]

   hFile = OPEN "/home/bungayst/scrap/sample_tabbed_text" FOR INPUT
   WHILE NOT Eof(hFile)
         LINE INPUT #hFile, LineInput
   WEND
   CLOSE hFile

   LineInput = Replace$(LineInput, "<BR>", "\n")
   TextArea1.Text = LineInput
   SplitString = Split(LineInput, "\t")

   FOR EACH ScrapString IN SPlitString
       PRINT ScrapString
   NEXT
END


richard terry wrote:
> See the attached file for the data. Unfortunately I'm brain dead when it comes 
> to simple logic.
> 
> In one of my hl7 messages in the Free Text segment under an actual pathology 
> result, there is a list of sequential bood test results representing previous 
> results of the same type - , separated by tabs which I need to display 
> properly. as I've re-constructed the result as html, the tabs simply 
> disappear in the result, so I've been looking for a solution, and to start I 
> thought maybe I could split this up into lines and then later put it into a 
> table embedded in the html to keep it aligned.
> 
> Perhaps there is a simple way out, but this is what I've done so far.
> 
> 
> So I started with this:
> 
> 1) Split this into lines
> 
> Dim bits as string[]
> dim a_line as string
> 
> bits = split(the_text_in_the_file,"<BR>,"", TRUE)
> 
> for each a_line in bits
> 	print a_line
> next	
> 
> Problem with this is that the \t (I presume tab character) gets in the way, 
> and it dosn't split properly with the results of the bits[] as shown in the 
> picture. Interestingly an occasional letter is lost off the test names.
> 
> Any help appreciated.
> 
> richard
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
> Series Scanner you'll get full speed at 300 dpi even with all image 
> processing features enabled. http://p.sf.net/sfu/kodak-com
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user




More information about the User mailing list