vyp_007
13th November 2006, 08:42
Hi,
How can I find comma seperated values from a string in BaaN. For example I have a string
MyString = "MTRZ1, MTRZ2, MTRZ3,MTRZ4"
I want to run a loop which will keep on finding each comma seperated values form MyString upto the last value i.e. MTRZ4. Is there any command to do so...?
Regards,
VYP
george7a
13th November 2006, 08:54
Hi,
If you always have 3 commas you can use the string.scan() function (http://www.baanboard.com/programmers_manual_baanerp_help_functions_formatting_io_string_scan) to get your strings in one command. If everytime you have a different number you will have to use the pos() function (http://www.baanboard.com/programmers_manual_baanerp_help_functions_string_operations_pos_rpos) to find the position of the comma then to cut the string and find the next comma...
I hope it helps
- George
vyp_007
13th November 2006, 10:26
Hi George,
I am unknown to the number of values in the input string which will be comma seperated. Also I want to copy each individual files which is nothing but the comma seperated value from one directory to another directory.
Do you have any example where from a string many values have been seperated and some operation is done on them.
Regards,
Vishal
george7a
13th November 2006, 10:38
Hi,
Here you go:
MyString = "MTRZ1, MTRZ2, MTRZ3,MTRZ4"
i = 1
pos1 = pos(MyString,",") | find the position of the first string
while pos1 > 0
Out.str(1,i) = MyString(1;pos1-1) | This array will have all the values of the strings.
MyString = MyString(pos1+1) | remove the first value
pos1 = pos(MyString,",") | find a new comma
i = i + 1
endwhile
Out.str(1,i) = MyString | last value...
You could do something similar using string.scan() too.
I hope it helps,
- George
vyp_007
15th November 2006, 08:55
Hi George,
The code provided by you has solved my problem. Thank you very much.
Regards,
VYP