STRLEN on the fly

I have a textbox with a variable of type “text” defined and length equal to 160. I want to be able to count the stringlenth along as the user types in the field - the “standard” Navísion function STRLEN isn’t enough, because it finds the strinlength after you have typed ENTER and I want to do it on the fly

The “OnInputChange” trigger, of the control on the form might solve your issue… haven’t tested it, but the online help says:


The system executes this trigger after it executes OnBeforeInput. It will continue to execute this trigger, after each keystroke, until the user finishes input. The system then executes the OnAfterInput trigger.

Saludos Nils

You don’t need any code like that. Navision will not allow you to enter more than the variable can hold. I tested this by adding a textbox to a form with a text variable with a length of 5. When pressing the 6th key, Navision will beep, and it will not let you enter more then the 5th character.

Hi! Daniel: Yes, I’m aware that you can’t type more characters than the length of the variabel defines ( by Type=Code/Text), but that’s not what I’m looking for. Nils: This is a bit closer to the solution! I’ve allready tried this, by putting a counter on this trigger, which step 1 upwards everytime the trigger is called. Since the trigger is called by every keystroke it also conuts backspace and arrow-to-the-left, and that’s not good! I want to create a counter, so that the user can keep an eye of the number of characters (also blancs) he has typed: Think of an SMS where you have a limited number of charaters. Jens

I wasn’t aware that the actual field doesn’t contain the string until the user leaves the field, therefore the actual typed string is not available… for the moment I have to keep on thinking… Saludos Nils

Maybe a step in the right direction? Using CurrForm.UPDATE in the OnInputChange makes the value of the variable available. [:(] After that the text in the textbox is selected, so typing another character overwrites that text.

If this was really really important, then one would write an automation dll in C#, or VB, where this is easily created.´ But this would require installation on all your more than 100 users’ computers. So…

I spent a lot of time trying this, and never found a solution. I was at the time trying to create an autosearch function, which eventually Navision added as standard in one of the more recent versions. If anyone has ever found a way to do this I would be very interested.