BaanTech
4th March 2003, 19:35
Is there a function for checking for a specific character
in a string.

Normally I just use a loop using i and step via (i;1) per
character until I find what I need. Ultimately (i) gives the
value where the character exists.

I use this simple code over and over to get what I need
and it works well for verifying layouts via flat files where
inconsistencies may exist (using traces on known fixed
characters), but one of our developers is asking if there is another way.

Thanks.

BaaTech

NPRao
4th March 2003, 19:50
You can use the standard tools function - pos(), rpos() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_string_operations_pos_rpos)

BaanTech
4th March 2003, 20:08
The example I was given was that the developer was asked to extract only the city name from Customer city field. normally the entry in this field is city, province or city, state and the developer only wants to extract the contents before the comma.

I would find the position of the comma and then extract the city using tccom010.name(1; i-1).

How would the mentioned function be used.

Regards,

BaanTech

evesely
4th March 2003, 20:26
Try:


long i

i = pos(tccom010.name, ",")


Of course, you should check that i isn't zero. Otherwise, you will get problems in running your statement.

sbakshi
4th March 2003, 20:29
Hi,

Try using string.scan

Say you want name and city seperated and in the field the seperator is "," then

long ret

ret = string.scan(fieldname,"%s,%s",name,city)

where fieldname is a string
and name,city are your defined variables...


Thanks