[WD23] How to insert a string at cursor position? [Solved!] October 05, 2020 03:44PM |
Registered: 5 years ago Posts: 121 |
MySelf = Left(MySelf, MySelf..Cursor) + sString + Right(MySelf, MySelf..Cursor)Unfortunately that does not work. When I am testing, regardless where the cursor is (it is in the field!), it keeps the first and the last character of Myself and puts the sString between them. Everything else in Myself is sent to bit-heaven.
Re: [WD23] How to insert a string at cursor position? October 06, 2020 08:24AM |
Registered: 5 years ago Posts: 112 |
Harry
Re: [WD23] How to insert a string at cursor position? October 06, 2020 01:13PM |
Re: [WD23] How to insert a string at cursor position? October 06, 2020 08:27PM |
Registered: 5 years ago Posts: 121 |
Re: [WD23] How to insert a string at cursor position? October 07, 2020 10:20AM |
Registered: 5 years ago Posts: 112 |
Re: [WD23] How to insert a string at cursor position? October 07, 2020 12:54PM |
Registered: 5 years ago Posts: 121 |
Re: [WD23] How to insert a string at cursor position? October 07, 2020 01:03PM |
Registered: 5 years ago Posts: 112 |
Re: [WD23] How to insert a string at cursor position? October 07, 2020 02:35PM |
Registered: 5 years ago Posts: 192 |
Re: [WD23] How to insert a string at cursor position? October 07, 2020 03:05PM |
Registered: 5 years ago Posts: 121 |
Re: [WD23] How to insert a string at cursor position? [Solved!] October 07, 2020 04:53PM |
Registered: 5 years ago Posts: 121 |
//This is the code in the "Key down" event of the text control: //============================================================= sPos is int = MySelf..Cursor //The cursor position must be saved first! sString is string = "" IF KeyPressed(kpControl) AND KeyPressed(Asc("G")) THEN //G = "Get" //Select the text to be inserted from a parameter file: IF Open("YPARAMI_TBLQ_PARKOHDE","Select","TEXT","STD","",0,"","",sString) THEN //Cut the text in two parts and insert sString between them: nLenS is int = Length(sString) //Length of sString sLeft is string = Left(MySelf,sPos) //The first part nLen1 is int = Length(sLeft) //Length of the 1st part sRight is string = Middle(MySelf,sPos) //The 2nd part MySelf = sLeft + sString + sRight //Concatenate all //Place the cursor at the end of the inserted string: MySelf..Cursor = nLenS + nLen1 + 1 Soundi("DONE") //Wake up the user END ENDThank you Arie for opening my eyes! Thanks also to Vassilis and Harry; it's always good to get suggestions from other developers. It makes one think the problem from many sides.