[futurebasic] Re: [FB] Edit Fields

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

From: AlStaff@...
Date: Thu, 26 Aug 1999 00:57:50 EDT
>>>>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?<<<<


Here's an example that works with more than 255 characters in a field.

WINDOW 1
ed$ = "Hello Al." + CHR$(13) + "You're the greatest!"
ed$ = ed$ + CHR$(13) + "Thanks for sending this."
ed$ = ed$ + CHR$(13) + CHR$(13) + "Press mouse to continue."
EDIT FIELD 1, ed$, (10,10)-(200,300)
WHILE FN BUTTON = 0
 HANDLEEVENTS
WEND

dum$ = ""
nlines = 0
GET FIELD txtH&, 1
LineWeWant = 2                                    ' this is the line of text 
to grab

LONG IF txtH&
 osErr = FN HLOCK (txtH&)
 size& = FN GETHANDLESIZE(txtH&)
 nlines = 1
 FOR X = 2 TO size& - 1
  dum$ = CHR$(PEEK([txtH&]+ X))
  LONG IF dum$ = CHR$(13)
   nlines = nlines + 1
   LONG IF nlines = LineWeWant + 1
    X = size&
   XELSE
    textArray$ = ""
   END IF
  XELSE
   textArray$ = textArray$ + dum$
  END IF
 NEXT X
 osErr = FN HUNLOCK (txtH&)
 DEF DISPOSEH(txtH&)
END IF

EDIT FIELD CLOSE 1
DELAY 500
CLS
PRINT "Line " LineWeWant " = ";
PRINT textArray$
PRINT : PRINT "----------"
INPUT "Press RETURN to end"; X$
END


Al Staffieri Jr.

AlStaff@...
http://members.aol.com/AlStaff/index.html