[futurebasic] Re: [FB] Edit Fields

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 1999 : Group Archive : Group : All Groups

From: Morrison SoftDesign™ <info@...>
Date: Wed, 25 Aug 1999 15:28:48 -0400
Use this:

CLEAR LOCAL
LOCAL FN parseText$(theText$,whichLine%)
  DIM countChr%, nextElement%
  DIM CRpos%(32000)
  
  DEC(whichLine%)
  FOR countChr% = 1 TO LEN(theText$)
    LONG IF MID$(theText$,countChr%,1) = CHR$(13)
      INC(nextElement%)
      CRpos%(nextElement%) = countChr%
    END IF
  NEXT
END FN = MID$(theText$,CRpos%(whichLine%),CRpos%(whichLine%+1)-CRpos%(whichLine%))

John


Joe Lewis Wilkins wrote:
> 
> MCB1985@... wrote:
> 
> > Hello. This is my first message sent out here... I am kind of a beginner... I
> > have created the Simple Wrestling Simulator, which you may recognize the name
> > of. (www.angelfire.com/il2/SimpleWrestlingSim/index.html)
> >
> > Anyway, here is my question. After the user types many things into the edit
> > field, using carriage returns so there are many lines, how would I get the
> > text from just one line? For example, if they typed...
> >
> > Hello
> > My Name is...
> > Goodbye
> >
> > If I only wanted to get what was in the second line ("My Name is..."), how
> > would I do it? Thanks in advance!
> 
> Hi MCB1985,
> 
> This is my hack. If someone can show me a better way, I'd love to see it.
> 
> txt$ = EDIT$(efNum%)                              'Pick up text from the Edit
> Field
> length% = LEN(txt$)                               'How long is the text?
> secondLine$ = ""                                  'Initialize an empty string
> firstReturn% = _false                             'No returns yet
> secondReturn% = _false                            'Not end of 2nd Line
> CR$ = CHR$(13)                                    'Carriage Return
> FOR i% = 1 TO length%                             'Go thru all chars
>   aChr$ = MID$(txt$,i%,1)                         'Look at each character
>   LONG IF aChr$ = CR$
>     LONG IF firstReturn% = _false
>       firstReturn% = _true                       'ID the beginning of second
> line
>     XELSE
>       GOTO "Have2ndLine"                       'No more to second line
>     END IF
>   END IF
>   LONG IF firstReturn% = _true and aChr$ <> CR$
>     secondLine$ = secondLine + aChr$
>   END IF
> NEXT i%
> "Have2ndLine"
> 'variable secondLine$ will contain the second line of text
> 
> You'll love FB, Joe Wilkins


-- 
Morrison SoftDesign
Professional Font Software
1-800-583-2917
http://www.MorrisonSoftDesign.com
-
Winner of the MacToday 1998 Editor's Choice Award!
http://www.mactoday.com/janfeb99/edchoice.html