Announcement

Collapse
No announcement yet.

Reading a paragraph into a single variable?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reading a paragraph into a single variable?

    I am trying to write an "obituary organizer" of sorts for my genealogy work. To make a long story short, suppose an obit (made up) says:

    James William Smith, age 82, died at his home Monday, July 18, 2005. Suvivors include[list of survivors]. Services were at [place]. Conducting the graveside service was [name]. Pallbearers were [names]. Burial was at [name]. Preceding in death were [names]. James like to [names of hobbies, favorite activities]. Name of funeral home is [name]. (And so on for the rest of the obit.)
    *******************

    Ok, is there a faster way to read in paragraphs of text into one field? Right now, I am reading it one character at a time and appending it to the field until I hit an asterisk.

    After I hit the asterisk, I proceed to extract the information I want to save, but perhaps there is a faster way to do this?
    After I extract the information I want to save, I import it into my genealogy program.

    I am using Power Basic for Dos.

    Thank you.

    Robert

    ------------------




    [This message has been edited by Robert E. Carneal (edited June 10, 2006).]

  • #2
    If all the information is in one text 'blob' you can
    Code:
     s$         = (the blob of text)
     TheStory$  = ""
     StartPos   = 1
     iPos = INSTR (startpos, blob, "*")
     WHILE iPos
        Thepara$ = MID$ (s$, StartPos, ipos-StartPos+1)
        ThePara  = ThePara + (whatever goes at the asterisk) _
                  + CHR$(13)+CHR$(10)     ' add 'newline' at end of para
        TheStory = TheStory$ + ThePara$
        StartPos = Ipos           ' position to first asterisk 
        WHILE MID$(S$, StartPos,1) = "*"  ' go past all asterisks found here
           INCR   StartPos
        WEND
        iPos    =  INSTR(startPos, S$, "*")  ' find next asterisk in S$
     WEND
     ' add any closing paragraph to TheStory$ here
    ' (if blob of text did not end in asterisk)
    MCM


    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Have you tried the Line Input? i.e.,

      open "somefile.txt" for input as #1
      do until (something happens)
      line input #1,temp$
      if left$(temp$,1) = "*" then exit loop
      text$ = text$ + " " + temp$
      loop
      close #1

      Line Input ignores all other delimiting characters except the
      Cr/Lf.

      ------------------


      [This message has been edited by Mel Bishop (edited June 10, 2006).]
      There are no atheists in a fox hole or the morning of a math test.
      If my flag offends you, I'll help you pack.

      Comment

      Working...
      X