EDLINE$ (#ch, maxlen%, edit$)


EDLINE (DIY Toolkit Vol E)

The function EDLINE$ prints edit$ at the current text cursor position in #ch (there is no default channel) and allows you to edit it. A maximum length of maxlen% characters is allowed. The edited result is returned. Unlike INPUT, EDLINE$ will not finish with <UP> or <DOWN> but only after <ENTER> and <CTRL><SPACE> (also <ESC> on Minerva). Instead <UP> and <DOWN> move the cursor to the start and end of the string respectively; apart from that the usual keys for editing are used: <CTRL><LEFT> deletes the character to the left of the cursor, <CTRL><RIGHT> the character under the cursor.


100 CLS
110 REPeat ask_name
120 PRINT \"Please enter your name: ";
130 Name$ = "Billy the Kid"
140 Name$ = EDLINE$(#1,40,Name$)
150 PRINT "Your name is '";Name$;"' (y/n)? ";
160 ok$ = EDLINE$(#1,1,"y")
170 IF ok$ INSTR "yY" THEN EXIT ask_name
180 PRINT "Try again..."
190 END REPeat ask_name
200 PRINT "Hello,"!Name$;"!"


You need a special version of EDLINE$ to work correctly on Minerva and SMS. This version is included with the DIY Toolkit package.


EDLINE$ can be used to input numbers but you have to ensure that the entered text can be successfully coerced to a number, see CHECK% and CHECKF for that. EDIT$ is similar. Other routines for human input are for example: INPUT, INKEY$, ASK and REPLY.