I tried searching all over the internet for the answer and just could not find it.
I have a SSN field and I need to grab the last four digits and append it to another field (making a complete account number).
The SSN field already has a script for proper formatting of the SSN (thank you to the person who helped me with that) and it uses RawKeyDown to do its magic. Do I add this there, after the RawKeyDown, on CloseField or do I put it in the script of the account # field? My thought is, I don't want to break what the auto-formatting is doing.
Also, when reading back the data, how do I hide all but the last four digits with either a "*" or a bullet?
Thank you for your help.
Mike
[SOLVED] How do I put the last four characters of a field (string) in a new variable?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 361
- Joined: Wed Apr 27, 2011 2:12 pm
[SOLVED] How do I put the last four characters of a field (string) in a new variable?
Last edited by karmacomposer on Fri Jul 20, 2018 1:39 am, edited 1 time in total.
Re: How do I put the last four characters of a field (string) in a new variable?
If the ssn is formatted as you say, you could always just set the itemDelimiter (dictionary) to - or / or whatever you used for the formatting, then get item 3 of the field, which should be the last 4 numbers. You could also (if it isn't actually formatted) grab chars 6 to 9 of the field (characters, keyword, dictionary).
The code would look like -
...and unformatted -
The code would look like -
Code: Select all
// formatted ssn...
set the itemDelimiter to "-"
put item 3 of field "yourSsnField" into tmpLastFour
// your code for what you want to do with that...
Code: Select all
put char 6 to 9 of field "yourSsnField" into tmpLastFour
// your code for what you want to do with that...
-
- Posts: 361
- Joined: Wed Apr 27, 2011 2:12 pm
Re: How do I put the last four characters of a field (string) in a new variable?
Thank you. That was perfect! The 1st option worked a treat.
Mike
Mike