Hi,
I've made a function that makes a code from the initials of a customer name. The code is put into a field called 'newcode' and is later used as the index of the customer line in a database. How can it be scripted to check if the code made already exists, and if it does, to suffix this latest instance of it incrementally (by 1) to distinguish it from one or more previous similar codes? I've tried using the 'exists' and 'there is ' functions without success or any idea of the syntax for this context.
Check if text in field already existsalready exists
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 9733
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Check if text in field already existsalready exists
CAsba.
Is there only a single field where all these new codes are stored? If so, just (pseudo):
There are other, similar variants, such as. (pseudo):
Craig
Is there only a single field where all these new codes are stored? If so, just (pseudo):
Code: Select all
if yourNewCode is not in fld "newCode" then loadNewCode
Code: Select all
if yourNewCode is not among the words in fld "newCode" then loadNewCode
-
- VIP Livecode Opensource Backer
- Posts: 9733
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Check if text in field already existsalready exists
Rereading, in order to help you with the second part of your question, how to modify a new code where a copy already exists, tell me how the codes are entered into the field. One per line, for example?
In this way we can construct the currently non-existent handler "loadnewCode" so that it does the work in either situation.
Craig
In this way we can construct the currently non-existent handler "loadnewCode" so that it does the work in either situation.
Craig
Re: Check if text in field already existsalready exists
Hi Craig,
I wonder, is it possible to check if the text in field newcode is already being used in a datagrid, relating to another customer with the same initials on which the customer code is based . (The text in field newcode will be entered into the datagrid, but cannot be the same as another datagrid entry.)
I wonder, is it possible to check if the text in field newcode is already being used in a datagrid, relating to another customer with the same initials on which the customer code is based . (The text in field newcode will be entered into the datagrid, but cannot be the same as another datagrid entry.)
Re: Check if text in field already existsalready exists
Hi again, Craig,
Ignore my last, I got it working via a field as you suggested.
Ignore my last, I got it working via a field as you suggested.