how to input numbers automatically

User 6ba4d9dd23

20-06-2012 02:13:30

I input catalog ID manually by typing ATR-0001, ATR-0002, ATR-0003.... Is there an easier way to do this since I have thounsands compouds? Thanks.

ChemAxon 2bdd02d1e5

20-06-2012 08:34:13

If the catalog number corresponds to ID you can generate catalog number from ID using Calculated Field.


The code which generates it looks like:



int length = String.valueOf(cdid).length();
def s = ""
for (int i = 0; i < 5-length; i++) {
s = s + "0"
}
return "ATR-" + s + cdid


where number 5 in for cycle denotes resulting number of digits in catalog number.


Further you can convert calculated field to string if you need to search the field.


Hope it helps. Filip...


ChemAxon 99d87cf303

20-06-2012 09:07:05

Better expression is just:


sprintf("ATR-%05d", cdid)

Cheers,


- m.

User 6ba4d9dd23

20-06-2012 12:14:04

Thanks for your reply. I am not a computer guy, so I just paste the code you wrote. But it did not work. Could you give more detail to do this?


Thanks.

ChemAxon 99d87cf303

20-06-2012 12:42:12

Hi. You have to press 'Add' button in the 'New calculated field' dialog. There you have to select the 'CdId' field (if your ID has such name) and confirm by pressing 'OK' button. Then it should work.

Cheers,
- m.

ChemAxon 99d87cf303

20-06-2012 12:44:20

More information about calculated fields might be found here: http://www.chemaxon.com/instantjchem/ijc_latest/docs/user/help/htmlfiles/editing_database/fields_calc.html


Let us know if you need more help.


Cheers,
- Martin

User 6ba4d9dd23

20-06-2012 18:56:47

Hi,


Thanks. It works.

User 6ba4d9dd23

03-07-2012 04:12:38

Hi,


Another question. If I want start catalog number as ATR-3 instead ATR-1, what code should I use? Thanks.

ChemAxon 99d87cf303

03-07-2012 06:51:51

If I understand you correctly, this should work for you:


sprintf("ATR-%d", cdid+2)

Cheers,
- Martin