A
ag07
Guest
I have the following code to check the number of several different substrings in a string. My method works, but I know there must be a more efficient way to code this. I have tried using for loops, but haven't got them working.
I
Create event:
s_count = 0;
count = 0;
Key Release Alt event:
1:
if (count < 3) {
count += 1;
}
2:
switch (count) { // go thru all 3 substrings, search main string for each one
case 1:
word = "cherry";
if (string_15 != -1) {
if (string_pos(word, string_15) != 0) {
scount = string_count(word, string_15);
}
}
break;
case 2:
word = "berry";
if (string_15 != -1) {
if (string_pos(word, string_15) != 0) {
scount = string_count(word, string_15);
}
}
break;
case 3:
word = "orange";
if (string_15 != -1) {
if (string_pos(word, string_15) != 0) {
scount = string_count(word, string_15);
}
}
break;
}
Is it practical to use nested loops to do this?
Please help me make it more efficient
Thank you
I
Create event:
s_count = 0;
count = 0;
Key Release Alt event:
1:
if (count < 3) {
count += 1;
}
2:
switch (count) { // go thru all 3 substrings, search main string for each one
case 1:
word = "cherry";
if (string_15 != -1) {
if (string_pos(word, string_15) != 0) {
scount = string_count(word, string_15);
}
}
break;
case 2:
word = "berry";
if (string_15 != -1) {
if (string_pos(word, string_15) != 0) {
scount = string_count(word, string_15);
}
}
break;
case 3:
word = "orange";
if (string_15 != -1) {
if (string_pos(word, string_15) != 0) {
scount = string_count(word, string_15);
}
}
break;
}
Is it practical to use nested loops to do this?
Please help me make it more efficient
Thank you