To change a specific number in a list in Max/MSP
uforange
7月 07 2024 | 1:51 午前
Hello,
I have a question. I want to convert texts to ASCII codes and then output 1 if it corresponds to 'a', 'e', 'i', 'o', or 'u', otherwise output 2. For example, if I input "book" with the atoi object, it converts to ASCII codes 98 111 111 107. If these values correspond to the ASCII codes for 'a', 'e', 'i', 'o', 'u' (97, 101, 105, 111, 117), it should output 1, otherwise 2. So, the letters in "book" should be output as "2 1 1 2". Could you please let me know how to do this? Thank you very much.
Roman Thilenius
7月 07 2024 | 2:32 午前
you will use sel, i will use expr:
[if ($i1==97) || ($i1==101) || ($i1==105) || ($i1==111) || ($i1==117) then 1 else 2]
[expr ( 2 - ($i1==97) || ($i1==101) || ($i1==105) || ($i1==111) || ($i1==117) )]
uforange
7月 07 2024 | 3:12 午前
Thank you for your response. My issue might be that the numbers are in a list, and I need to apply the if statement to each number individually. Is it possible to use $i1 for this? It might be difficult to convey the meaning through my text-based question alone, so I've attached an example which might be helpful. Thank you.
Source Audio
7月 07 2024 | 7:16 午前
![](https://cycling74-web-uploads.s3.amazonaws.com/58ed04e7285705c15ccfa694/2024-07-07T07:16:28Z/image.png)
uforange
7月 07 2024 | 5:29 午後
@SOURCE AUDIO Wow, this is amazing! Thank you very much!
uforange
7月 07 2024 | 5:38 午後
I'm personally curious if it's possible to apply an if statement to individual numbers in a number list?
Roman Thilenius
7月 07 2024 | 7:06 午後
if you use vexpr instead of expr, that one will also process lists.
![](https://cycling74-web-uploads.s3.amazonaws.com/574f1ffc3b4a14995d983d8f/2024-07-07T19:05:19Z/grafik.png)
but otherwise you can always do [iter] to the list in that situation.
uforange
7月 08 2024 | 7:21 午後
oh I see. This is great! Thanks Roman.