[futurebasic] Re: [FB] Edit Fields

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

From: Joe Lewis Wilkins <PepeToo@...>
Date: Wed, 25 Aug 1999 12:09:41 -0700
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