Normal Topic CEND (Read 2356 times)
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
CEND
Oct 29th, 2018 at 7:39pm
Print Post Print Post  
I am trying to make dynamic changes to an element TEST as data is entered.   This only happens if a certain character is typed.  The changes are made, a sound is made to alert operator. The Triggering character is deleted. (Problem is here, cursor is at start of string vs. at the end.) More data is entered into the same TEST element.

The change seems to work OK, but the cursor keeps returning to the beginning of the element, and I want it to return to the end of the data string being typed.  Now typist hears alarm,  has to see cursor is at beginning, and then hit END to continue typing.  Would like to be able to keep typing from last character.


[code]
ON IMMEDIATE CHANGE TRIGGER in Element TEST

If @Right(TEST,1) = Some value Then {
     Use @Replace to remove the last char
     // Modify the TEXT data for three strings
     TEST = @Replace(TEST,x,newx)
     TEST = @Replace(TEST,y,newy)
     TEST = @Replace(TEST,z,newy)
     @Play("Sound",400,500)
     CEND      
     }

CEND does not seem to do what I hoped.  I tried using CEND on Element Entry, by also no good.

What do I need to put in here vs. CEND to allow continuous typing?  How to have the cursor at the end of the last character?
  
Back to top
 
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: CEND
Reply #1 - Nov 1st, 2018 at 2:59pm
Print Post Print Post  
You could use CursorPosition to force the cursor to the end of the field.

Code
Select All
var vLen as Int
var vOriginal as String

vOriginal = Test

//Runs before any @Replace code and captures what was originally typed.

If @Right(TEST,1) = Some value Then {
     Use @Replace to remove the last char
     // Modify the TEXT data for three strings
     TEST = @Replace(TEST,x,newx)
     TEST = @Replace(TEST,y,newy)
     TEST = @Replace(TEST,z,newy)
     @Play("Sound",400,500)
     CEND
     }

vLen = @vLen(TEST)

//Some kind of criteria signifying that the @Replace code had to run/needed to run. Like maybe taking what was originally typed in the field and storing that in a variable and creating a second variable that stores the field data after the @Replace code runs. Then comparing the two and if they don't equal <> then the If statement runs.

If vLen > 0 Then
{
	If vOriginal <> TEST Then
	{
		CursorPosition(TEST, vLen)
	}
 



I don't know if this will work or not, didn't test it or anything but hope it helps.
  
Back to top
 
IP Logged
 
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: CEND
Reply #2 - Nov 1st, 2018 at 4:11pm
Print Post Print Post  
Totally forgot about CursorPosition.  Think I have used it once in all these years. 

Have not tested it here yet either, but will do this weekend.  Am pretty sure this will do it.

Thank you
  
Back to top
 
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: CEND
Reply #3 - Nov 2nd, 2018 at 3:22pm
Print Post Print Post  
No problem
  
Back to top
 
IP Logged
 
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: CEND
Reply #4 - Nov 5th, 2018 at 8:56pm
Print Post Print Post  
Thanks actiontech.  That was the answer.  Worked perfectly.
  
Back to top
 
IP Logged