Cursor Position

Hi All, The User can enter some Text for example ‘Hello Forum’ in a Textbox. After the input he places the Cursor after the ‘Hello’. Then by pressing a Button a Text, for example ‘#####’, should be inserted so that the result should look like ‘Hello##### Forum’. How can i manage this? Thanks in advance, Frank

download a little marco program from download.com. Define the typing of 5 # characters and links them to a short cut key. The best and only way to do this.

hi Eromein, thanks for your answer. But the Problem is, that the number of # varies and depends of several choices of the User. Is there no other way? [:(] Greetings, Frank

Ups… I mean…Hi Emiel…and not Eromein, sorry

np Frank… What you could so is the following. Make the user place ‘%1’ on the place the string should come. Then program the following in the OnPush of the button: var := strsubstno(var, string); **what's what?** var = texbox SourceExpr. string = the sting that should be included. Good luck!

Hi Frank My suggestion is almost the same like the one from Emiel. I would use a wildcard like @. This example is from the Item - card! **OnModifyRecord() : Boolean** Basic:= Description; Input:= 'YourText'; tmpTXT:= Basic; i:= STRPOS(Basic,'@'); IF i <> 0 THEN BEGIN Output:= COPYSTR(tmpTXT,1,i - 1) + Input + COPYSTR(tmpTXT,i+1); Description:= Output; END; It works but there is still one problem: You have to change the record to see the changes [:(]! bye Andre

Place the code into the OnValidate trigger of the field on the form. This should do the trick!

Hi Emiel

quote:


Originally posted by eromein
Place the code into the OnValidate trigger of the field on the form. This should do the trick!


YEP [:)]. Thank you! bye André

Hi Emiel, Hi Andre, Thanks for your answers. It works, but this is not what i really want. Here an example. Lets have a look at the comments of Items. In this form you have a second tablebox in which some Attributes of the item, the comment belongs to, will be shown. The User types his comment and on a position of his choice he select one of the Attributes and a shortcut for this Attribute will be inserted until his comment is correct. If this item is for example in a sales order the user has to fill the Attributes. In the Report the Comment will be printed and the shortcuts will be replaced with the values. Several Sales orders will have several values of the attributes of this item! What you tell me will work, but the user can make many errors by typing the shortcuts manual. I need a solution, where the user clicks ot one of the Attributes and the shortcut is inserted automatically. Is there any way to solve this problem? Greetings, Frank

Hi Frank You might use STRMENU. The user can select something and the system can fill the data / shortcut in your field. So you have always the control. Example Basic:= Description; tmpTXT:= Basic; i:= STRPOS(Basic,'@'); IF i <> 0 THEN BEGIN **NEW** ix:=0; REPEAT ix := STRMENU('XX Case 1,YY Case 2,ZZ Case 3'); UNTIL ix <> 0; CASE ix OF 1: Input:= 'XX Case 1'; 2: Input:= 'YY Case 2'; 3: Input:= 'ZZ Case 3'; END; **/NEW** Output:= COPYSTR(tmpTXT,1,i - 1) + Input + COPYSTR(tmpTXT,i+1); Description:= Output; END; bye Andre

Thanks again Andre, But thats not really what i want. What i need is something like this: By clicking the butten the chosen String is put in the Memory windows use for STRG+C and then “say” STRG+V, so that the chosen String is put in the Textbox at the place of the Cursor. Is there a tool or any other way to solve this? Regards, Frank

Hi Frank I’m afraid that will not work because you change the Form.Control by clicking on a button (textbox => button). IMHO you can’t save the cursor position (without a wildcard). bye André

Could you tell me again what this shortcut is? Maybe there is a other solution to silve this.

Hi Emiel, for every item exist some Attributes, for examble colour, length and width. If you put one item in a sales order then you have to fill these Attributes. In the Comment of the Item exist placeholder for the Attributes and if you print your sales order the values you have filled in are printed instead of the placeholders. Once you sell the item in colour ‘Red’ and in another sales order you sell it with colour ‘blue’. And in the sales order of the Item the placeholder in the Comment for the Attribute ‘colour’ is substituted with once with ‘Red’ and the other time with ‘blue’. The User should style his own comment for every item and place the placeholder where he wants. But to protect from errors the user should not type the palceholders by himself, he should choose one of the records an the placeholder is inserted automatically. A situation like two tableboxes on a form where in the first is the comment, in the second are all attributes and the user can “Drag & Drop” the Attributes in the Comment at every place is very usefull. I hope my explanation is good enough… Regards, Frank

Why not make a default comment per item. Which is then copied into the sales line item comment (Or whatever comment that is) and fill the placeholders automaticly. Sample: Default item comment = ‘You bought item %1 “%2” in a %5 variant. Oh… and it’s %3cm by %4cm’; %1 = Item No. %2 = Item Description %3 = width %4 = length %5 = Color So every Item attribute gets it’s own placeholder. Then on auto. coping it to the sales comments just subststrno it. Is that kinda what you need?

Hi Emiel, not really. Certainly the Comment muss look like ‘You bought item %1 “%2” in a %5 variant. Oh… and it’s %3cm by %4cm’ or something similar to this where the placeholders are replaced during printing with the corresponding values. But the situation before is problematic. The user should configure the Comment for every item if he wants. And during this he need to fill in some placesholders. But the user should not type %1 or %2 by himself. This creates too many errors. It is the way how to put the right placesholder for the attributes at the desired position into the text. But what is the best way??? Is there any other way??? As you and Andre said before, it is easy to solve it, if the user types his text and the placeholder has to be filled in at the end of the text. But how can i solve the problem if the user want to place a placeholder in the middle of the text? Greetings and many thanks Emiel and Andre, Frank

Frank, you have to face the fact your wishes can’t be granted. :wink: I really think you should think of another solution. What you want just can’t be done. If you want to decrease user input errors you should think about thing like predefined comments or automaticly generated textstring which can be modified by users. But just remember, if enduser want to mess up data, they can and will do anyhow. This can not be blamed on the software.

Hi Emiel, I sadly think you are right. I’ve just developed such a solution in another Programm in another Language. Many many thanks for your effort and thoughts. Frank

yw dude!

I’ve done something very similiar, but I did it a little differently. I have a standard set of comments that get added at times, and I wanted to do exactly as you had done, so what I did was create a new form. In this form, I created text boxes where users could fill in the values that they needed. Then, using the %1, %2, etc. method, I was able to contsruct the comment to be entered after they hit a button. An alternate form will probably have to be created.