try the Left() function
If ( Left(fieldname; 3) = "AOT" ... )
Of course that is only part of the test. What do you want to do with the results?
A calculation field can be created that is just:
Left ( FIELDNAME ; 3 ) // return the first 3 characters
Then you can use the value, search the field, sort the field, etc.
1 of 1 people found this helpful
And you can FIND in you field as searches are already "begins-with".
Enter Find mode
Set Field ( FIELDNAME ; "AOT*" )
no need for a calculation. again it depends on what you want to do with the value(s).
Yes, sorry. I am using it in an if statement and triggered on an object save as the field is left. I didn't want to use a validation calc for it. Then will use a custom dialogue if it doesn't start with "AOT" because I know it was entered incorrectly. I have some others for length of char, etc..
Then Beverley's suggestion on using the Left function would seem appropriate. But I'd consider OnObjectValidate instead of OnObjectSave if you are using a script to validate the input. This gives you better options for how your script can respond to data entry errors that fail the script's validation test.
Yes that seems to be the best option. Thanks to you and beverley. Great community!
Here's a generalized custom function that you might want to consider:
// StartsWith ( text; startString )
// This function determines if a text value starts with a particular substring:
// • Returns 1 (true) if it does; 0 (false) if it doesn't.
// • text The text to be checked
// • startString The substring we're looking for
// Exception Conditions:
// • If the text value is empty or is not as long as the starting string, return 0.
// • If the text value is nonempty but the starting string is empty, return 1 (a null substring is an automatic match).
// The match is NOT case-sensitive.
startStringLength = Length ( startString ) ;
/* No text to search */ IsEmpty ( text ) ; 0 ;
/* Not enough text to search */ Length ( text ) < startStringLength ; 0 ;
/* Empty match string */ startStringLength = 0 ; 1 ;
/* Check for a match */ Left ( text ; startStringLength ) = startString