Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5855 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi, I have a text field that the user enters information into. I also have a series of button that inserts text into this field.

The problem is I have only been able to have it insert at the end of the field.

Does anyone have an idea how to have the insert done where the cursor is located?

Thanks,

Posted

Have your Button use

Insert Calculated Result []

Posted

Thanks for replying.

I have been using Insert Calculated Result [].

For whatever reason, it inserts at the end instead of the location of the cursor.

Posted

Consider the SetField Script step and the functions:

Let () Middle ( ) Replace ( ) Substitute

Just a simple example...

Let([

MyField = Fieldxyz;

LengthMyfield = Length( Fieldxyz) ;

Target = "." ;

TargetPosition = Positions (MyField ; Target ; 1) ;

NewPhrase = UserField ] ;

Replace( MyField ; Target ; NewPhrase) ) >> or>>

>> or>>

Middle(MyField ; 0: TargetPosition-1 ) &

NewPhrase & " " & Middle(MyField ; TargetPosition B) LengthMyfield-TargetPosition )

You can use the functions, Position, Count, Middle and Replace to insert phrases into phrases as long as there are consistant markers for the start and end and location for where a phrase should go. Think what do I want this text to go, how do I know where the destination text starts, ends and how do I know where the target is. Be aware of the differences between Substitute (requires knowing what text is replaced) and Replace (requires knowing the exact location (characters from a certain point where repacement will occur). If a 'marker" occurs only once or all "markers" can/will be replaced, Substitute is easier to use.

The above is just off the top of my head but I think you get the idea.

Good Luck.

PS

Here is a calculation I use to insert date or reason in to stock phrases such as "Please excuse from XXX from AAA to BBB due to YYY." Where AAA and BBB are blank markers for dates and XXX and YYY are blank markers for conditions. The staff selects the appropriate phrase from the portal fills in the date/Text fields that are formatted with calender vaule list or text value list respectively then print the excuse.

Let([

OptionField = PatientNote_TotalRaw ;

BlankDateAA = PatientNote_BlankDateA ;

BlankDateBB = PatientNote_BlankDateB ;

BlankDateCC = PatientNote_BlankDateC ;

BlankTextXX = PatientNote_BlankTextX ;

BlankTextYY = PatientNote_BlankTextY ;

BlankTextZZ = PatientNote_BlankTextZ ;

FinalTextAAA = Case( (PatternCount ( OptionField ; "AAA" ) > 0) and ( IsEmpty ( BlankDateAA ) = 0) ; Substitute ( OptionField ; "AAA" ; BlankDateAA ) ; OptionField ) ;

FinalTextBBB = Case( (PatternCount ( FinalTextAAA ; "BBB" ) > 0) and ( IsEmpty ( BlankDateBB ) = 0) ; Substitute ( FinalTextAAA ; "BBB" ; BlankDateBB ) ; FinalTextAAA) ;

FinalTextCCC = Case( (PatternCount ( FinalTextBBB ; "CCC" ) > 0) and ( IsEmpty ( BlankDateCC ) = 0) ; Substitute ( FinalTextBBB ; "CCC" ; BlankDateCC ) ; FinalTextBBB ) ;

FinalTextXXX = Case( (PatternCount ( FinalTextCCC ; "XXX" ) > 0) and ( IsEmpty ( BlankTextXX ) = 0) ; Substitute ( FinalTextCCC ; "XXX" ; BlankTextXX ) ; FinalTextCCC) ;

FinalTextYYY = Case( (PatternCount ( FinalTextXXX ; "YYY" ) > 0) and ( IsEmpty ( BlankTextYY ) = 0) ; Substitute ( FinalTextXXX ; "YYY" ; BlankTextYY ) ; FinalTextXXX ) ;

FinalTextZZZ = Case( (PatternCount ( FinalTextYYY ; "ZZZ" ) > 0) and ( IsEmpty ( BlankTextZZ ) = 0) ; Substitute ( FinalTextYYY ; "ZZZ" ; BlankTextZZ ) ; FinalTextYYY ) ] ;

Case(

IsEmpty ( OptionField ) = 1 ; "" ;

FinalTextZZZ ) )

Posted (edited)

Do not select a target field and also make sure that the select entire contents is unchecked.

Insert_Text.zip

Edited by Guest
added file
Posted

I have been using Insert Calculated Result [].

For whatever reason, it inserts at the end instead of the location of the cursor.

The most likely reason is that your button is located in a portal, causing your target field to lose focus when you click the button.

Posted (edited)

Both these statements fit the problem.

mr_vodka

Do not select a target field and also make sure that the select entire contents is unchecked.

comment

The most likely reason is that your button is located in a portal, causing your target field to lose focus when you click the button.

I will change the first.

I understand the reason for the second, but to change this definitely presents a problem.

I have included a screen capture of the layout. I hope this shows my predicament.

The black squares in the portals are the buttons for the scripts.

It would appear that I am stuck with the problem, unless I can find another way to start these scripts.

Thanks.

I am thinking about using a checkbox, and having the actual button outside the portal. This might work.

Image1.jpg

Edited by Guest
Second Thought
Posted

This is indeed a predicament, and I don't know of a really good solution for it. However, there's a way to hide the issue and make it into a "feature": instead of showing the three portals, show 3 buttons, each running the same script with a different parameter.

The script would start by storing the active selection start and size into variables, then display the entries with the chosen category and pause. After user's selection, store the selected value in another variable, hide the entries, restore the active selection to the target field, and only then insert the variable as calculated result into the field.

This topic is 5855 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.